Below are some issues we encountered during our first real deployment of gevent. It is being used on one host to communicate over ethernet (ie, using raw ethernet packets) with approximately 700 PIC32 microprocessors, and it is used for communication between all of the services we have built (approximately 15 unique services running on two hosts).
-
The majority of the issues we faced were caused by a particular service which communicates with a child process over
stdin
/stdout
. Not all of the issues were gevent specific (for example, when the child wasn't properlyselect
ing on stdout, the kernel was silently dropping data when its internal buffer filled up, even thoughfwrite
reported that the data had been written). -
We are using
gevent-0.13.7
withlibevent-2.0.x
. I would like to be usinggevent-1.0
, but it was causing some issues (I don't recall exactly what they were) on OS X, so we rolled back to 0.13.7. -
libevent-1.4.13-stable
(packages with Debian stable 6.0.4) would, under moderate load, block indefinitely on calls towait_write
(manually creating anEV_WRITE
event had similar issues). I wasn't able to fully diagnose this issue, as my co-worker was able to upgrade tolibevent-2.0.19-stable
which made the issue go away. -
It's not obvious how to perform non-blocking I/O on generic file descriptors. There isn't an obvious non-blocking version of
os.read
/os.write
. After some searching, the trick is to manually usefcntl
to setO_NONBLOCK
, then usewait_read
andwait_write
. From the process.py example:```python fcntl.fcntl(stdin, fcntl.F_SETFL, os.O_NONBLOCK) wait_read(stdin.fileno()) data = os.read(stdin.fileno(), 4096) ```
-
Note that
gevent-1.x
will incluegevent.subprocess
, which will make subprocess fiddling simpler. -
There have been a copule of instances where it would have been nice to use kernel threads, but this hasn't been a huge issue, and
gevent-1.x
will allow kernel threads.
Please note: this is in no way a criticism of gevent. We (the two developers) are very happy with our decision to depend so heavily on gevent: it has simplified many aspects of development (just to name a few things that come immediately to mind): we simply don't have intra-process concurrency-related bugs, the deterministic nature of cooperative multithreading makes debugging and testing easy, and the Timeout
context manager is great.