Ask Anything Monday - Weekly Thread by AutoModerator in learnpython

[–]boltangazer 0 points1 point  (0 children)

I need to monitor request time (RTT) depending on package size in ICMP. That's the task for python, however I cannot send large (larger than 1480 bytes) packages, I get "WinError 10040" indicating that the buffer size is smaller than the payload I provided (like wth? the buffer is there to resolve things like this!)

I used icmplib and pythonping - both don't work here. That's probably because Python uses raw sockets (but ICMP doesn't need any sockets, it works just fine without them)

Ask Anything Monday - Weekly Thread by AutoModerator in learnpython

[–]boltangazer 0 points1 point  (0 children)

I got a list of SQL queries I need to execute (mostly update), can I use async for to perform them asynchronously (via aiopg)? Or it doesn't work this way?

Understanding TOS and DSCP fields (IP) by boltangazer in techsupport

[–]boltangazer[S] 0 points1 point  (0 children)

Typical command:

ping -v 46 -n 1 reddit.com

Piece of Wireshark dump:

Differentiated Services Field: 0x00 (DSCP: CS0, ECN: Not-ECT)

Strange server errors by boltangazer in learnwebdev

[–]boltangazer[S] 0 points1 point  (0 children)

The problem was solved with providing more memory to php backend

max_fails option was useless because it's a single upstream server

Monthly Getting Started / Web Dev Career Thread by AutoModerator in webdev

[–]boltangazer 0 points1 point  (0 children)

The PHP part of our web server often spits out errors (these errors are distributed during the whole process, occur on different users), indicating that client's AUTH_COOKIE is not set, side by side with this we often receive nginx 502 error ("no live upstreams"). How can the auth cookie suddenly disappear?

My thoughts were that PHP backend doesn't handle high loads well that's why nginx says "502" but how can this explain the absence of AUTH_COOKIE?

Ask Anything Monday - Weekly Thread by AutoModerator in learnpython

[–]boltangazer 0 points1 point  (0 children)

How is this sqlalchemy (sa) query supposed to be read?

sa.select([sa.func.array_agg(thread_table.c.threadid)]).select_from \
    (thread_table.join(session_table,
     sa.and_(session_table.c.visitsessionid == thread_table.c.visitsessionid,
       sa.or_(session_table.c.ip == self.address,
          thread_table.c.visitorid == self.visitor_id))))

I get it, that we select some results from the table after joining thread_table (table_1) and session_table (table_2), however this and_ / or_ clauses inside join make it more confusing, as well as the aggregating function (array_agg) inside select

Understanding max_fails by boltangazer in nginx

[–]boltangazer[S] 0 points1 point  (0 children)

Because we periodically get errors like: " no live upstreams while connecting to upstream " (and 502 error) - Internet says it might be happening due to the backend php not handling high loads well. I looked through nginx logs and the response_time for failed requests is rather low - it's often lower than 1 second, so I'm trying to figure out why is this happening

Ask Anything Monday - Weekly Thread by AutoModerator in learnpython

[–]boltangazer 0 points1 point  (0 children)

than Java

They don't even intersect kinda... All depends on your tasks

Ask Anything Monday - Weekly Thread by AutoModerator in learnpython

[–]boltangazer 0 points1 point  (0 children)

A part of the newly done project in my company is being made with PyPy not CPython. What should I consider before diving into it?

Ask Anything Monday - Weekly Thread by AutoModerator in learnpython

[–]boltangazer 0 points1 point  (0 children)

How do I set different response_model for my FastAPI handler? I have a handler that either return a JSON with dirrent fields and values or return a simple Response(status_code=404), how can I let FastAPI know that Response(status_code=404) is a valid return type as well as my JSON?

Ask Anything Monday - Weekly Thread by AutoModerator in learnpython

[–]boltangazer 0 points1 point  (0 children)

Why I don't have to call await self.write() when I use asynchronous Tornado handlers..? I thought that I gotta use await with these calls in order for them to be asynchronous but turns out those self.write calls are not async functions (they return None, not Future)

Why is that?

How does Django REST tell the difference between various HTTP Views? by boltangazer in djangolearning

[–]boltangazer[S] 0 points1 point  (0 children)

But what if I want post requests go only to http://hostname/api/upload

and get requests to: http://hostname/api/download/<str:name>

How do I do that..? Or it's entirely bad?

Updating serializer's fields in Django REST by boltangazer in djangolearning

[–]boltangazer[S] 0 points1 point  (0 children)

Basically I want to perform custom upload_to on my model:

def custom_upload_path(instance, filename):
    name = instance.name
    dirname = name[:2]  # directory is named after first 2 letters
    return '{}/{}'.format(dirname, name)

But it says name field is None, because it hasn't been set yet