Questions tagged [gevent]

Gevent is a coroutine-based Python networking library that uses greenlet to provide a high-level synchronous API on top of libevent (libev after 1.0) event loop.

Gevent is a coroutine-based Python networking library that uses greenlet to provide a high-level synchronous API on top of libevent (libev after 1.0) event loop.

1147 questions
21
votes
3 answers

Python: unit testing socket-based code?

I'm writing a Python client+server that uses gevent.socket for communication. Are there any good ways of testing the socket-level operation of the code (for example, verifying that SSL connections with an invalid certificate will be rejected)? Or is…
David Wolever
  • 148,955
  • 89
  • 346
  • 502
20
votes
10 answers

How to efficiently do many tasks a "little later" in Python?

I have a process, that needs to perform a bunch of actions "later" (after 10-60 seconds usually). The problem is that those "later" actions can be a lot (1000s), so using a Thread per task is not viable. I know for the existence of tools like gevent…
Emil Ivanov
  • 37,300
  • 12
  • 75
  • 90
20
votes
1 answer

What is the cleanest way to stop a python multiprocessing worker attached to a queue in an infinite loop?

I'm implementing a producer-consumer pattern in python using multiprocessing.Pool and multiprocessing.Queue. Consumers are pre-forked processes that uses gevent to spawn multiple tasks. Here is a trimmed down version of code: import gevent from…
Vikas
  • 8,790
  • 4
  • 38
  • 48
20
votes
2 answers

What does make significant difference of performance between eventlet and gevent?

Those two libraries share the similar philosophy and the similar design decisions as a result. But this popular WSGI benchmark says eventlet is way slower than gevent. What do make their performance so different? As I know key differences between…
minhee
  • 5,688
  • 5
  • 43
  • 81
20
votes
5 answers

gevent monkey-patching and breakpoints

I have been playing with Gevent, and I like it a lot. However I have run into a problem. Breakpoint are not being hit, and debugging doesn't work (using both Visual Studio Python Tools and Eclipse PyDev). This happens after monkey.patch_all() is…
Flavien
  • 7,497
  • 10
  • 45
  • 52
19
votes
5 answers

how enable requests async mode?

for this code: import sys import gevent from gevent import monkey monkey.patch_all() import requests import urllib2 def worker(url, use_urllib2=False): if use_urllib2: content = urllib2.urlopen(url).read().lower() else: …
user12397901
  • 460
  • 1
  • 4
  • 14
19
votes
2 answers

gevent: downside to spawning large number of greenlets?

Following on from my question in the comment to this answer to the question "Gevent pool with nested web requests": Assuming one has a large number of tasks, is there any downside to using gevent.spawn(...) to spawn all of them simultaneously rather…
ARF
  • 7,420
  • 8
  • 45
  • 72
19
votes
1 answer

how to combine django plus gevent the basics?

After much searching and googling I am coming back to the well. I have Django 1.4 and am looking for a decent working example to figure out getting Django to work with gevent. I like the Django framwork but I need it to handle long polling. I…
Tereus Scott
  • 674
  • 1
  • 6
  • 11
18
votes
2 answers

Python async and CPU-bound tasks?

I have recently been working on a pet project in python using flask. It is a simple pastebin with server-side syntax highlighting support with pygments. Because this is a costly task, I delegated the syntax highlighting to a celery task queue and in…
nikitautiu
  • 951
  • 1
  • 14
  • 28
17
votes
1 answer

run web app with gevent

I want to try playing around with gevent as a web server and application framework. I don't see any way to "restart" the server or update the application code without killing and starting the whole python application again. Is this just how it's…
Endophage
  • 21,038
  • 13
  • 59
  • 90
17
votes
3 answers

Celery worker hangs without any error

I have a production setup for running celery workers for making a POST / GET request to remote service and storing result, It is handling load around 20k tasks per 15 min. The problem is that the workers go numb for no reason, no errors, no…
Maddy
  • 791
  • 1
  • 8
  • 22
17
votes
8 answers

I can't install Gevent

I need to install Gevent for python2.7 but after try almost all I still doesn't install it. I have python 2.6.6 and here all work ok... but I need python2.7+ then I install python 2.7.9 and now have only problems... Before some part of my project…
XnIcRaM
  • 263
  • 1
  • 3
  • 12
17
votes
3 answers

How can I pool connections using psycopg and gevent?

The psycopg docs state: "Psycopg connections are not green thread safe and can’t be used concurrently by different green threads. Trying to execute more than one command at time using one cursor per thread will result in an error (or a deadlock on…
gone
  • 4,342
  • 2
  • 24
  • 29
16
votes
1 answer

Stackless in PyPy and PyPy + greenlet - differences

New version of PyPy ships with integrated Stackless. As far as I know the bundled Stackless is not the same as the origin Stackless from 2001 with continuations. So mainly it is the green threads framework with dispatcher. Greenlet is a spin-of…
Robert Zaremba
  • 8,081
  • 7
  • 47
  • 78
16
votes
2 answers

ModuleNotFoundError: No module named 'gevent.wsgi'

I'm getting the following error while running a flask app: from gevent.wsgi import WSGIServer ModuleNotFoundError: No module named 'gevent.wsgi' gevent is already installed and the requirement is satisfied. Pip version is 10.11 and Python…
Praveen R
  • 699
  • 2
  • 7
  • 23
1 2
3
76 77