Websockets in Flask

In regular HTTP requests the connections between client and server are short-lived, a client connects to the server, sends a request, receives the response and then closes the connection. In this model the server can serve a large number of clients using a small number of workers. The concurrency model in this situation is typically … Read more

KeyError in module ‘threading’ after a successful py.test run

I observed a similar issue and decided to see what’s going on exactly – let me describe my findings. I hope someone will find it useful. Short story It is indeed related to monkey-patching the threading module. In fact, I can easily trigger the exception by importing the threading module before monkey-patching threads. The following … Read more

Byte Array in Python

In Python 3, we use the bytes object, also known as str in Python 2. # Python 3 key = bytes([0x13, 0x00, 0x00, 0x00, 0x08, 0x00]) # Python 2 key = ”.join(chr(x) for x in [0x13, 0x00, 0x00, 0x00, 0x08, 0x00]) I find it more convenient to use the base64 module… # Python 3 key … Read more

Greenlet Vs. Threads

Greenlets provide concurrency but not parallelism. Concurrency is when code can run independently of other code. Parallelism is the execution of concurrent code simultaneously. Parallelism is particularly useful when there’s a lot of work to be done in userspace, and that’s typically CPU-heavy stuff. Concurrency is useful for breaking apart problems, enabling different parts to … Read more

When to use Tornado, when to use Twisted / Cyclone / GEvent / other [closed]

“Django is a high-level Python Web framework that encourages rapid development and clean, pragmatic design”. If you are building something that is similar to a e-commerce site, then you should probably go with Django. It will get your work done quick. You dont have to worry about too many technology choices. It provides everything thing … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)