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
184
votes
4 answers

When to use Tornado, when to use Twisted / Cyclone / GEvent / other

Which of these frameworks / libraries would be the best choise for building modern multiuser web application? I would love to have an asynchronous webserver which will allow me to scale easly. What solution will give the best performance /…
Wojciech Danilo
  • 11,573
  • 17
  • 66
  • 132
156
votes
4 answers

Greenlet Vs. Threads

I am new to gevents and greenlets. I found some good documentation on how to work with them, but none gave me justification on how and when I should use greenlets! What are they really good at? Is it a good idea to use them in a proxy server or…
Rsh
  • 7,214
  • 5
  • 36
  • 45
118
votes
8 answers

Dynamically changing log level without restarting the application

Is it possible to change the log level using fileConfig in python without restarting the application. If it cannot be achieved through fileConfig is there some other way to get the same result? Update: This was for an application running on a…
opensourcegeek
  • 5,552
  • 7
  • 43
  • 64
92
votes
4 answers

Byte Array in Python

How can I represent a byte array (like in Java with byte[]) in Python? I'll need to send it over the wire with gevent. byte key[] = {0x13, 0x00, 0x00, 0x00, 0x08, 0x00};
d0ctor
  • 925
  • 1
  • 6
  • 6
70
votes
1 answer

Websockets in Flask

I'm currently researching websocket support in Python and am a bit confused with the offerings. On one hand it's possible to use Flask + gevent. On the other hand, uwsgi has socket support and at last there is an extension that bundles both uwsgi…
ruipacheco
  • 15,025
  • 19
  • 82
  • 138
68
votes
3 answers

KeyError in module 'threading' after a successful py.test run

I'm running a set of tests with py.test. They pass. Yippie! But I'm getting this message: Exception KeyError: KeyError(4427427920,) in
kkurian
  • 3,844
  • 3
  • 30
  • 49
65
votes
1 answer

Asyncio vs. Gevent

Background I once worked on a Python2 system that had a lot of custom I/O code written synchronously, and was scaled using threads. At some point, we couldn't scale it any further, and realised we have to switch to asynchronous programming. Twisted…
Dan Gittik
  • 3,460
  • 3
  • 17
  • 24
64
votes
10 answers

How can I install the Python library 'gevent' on Mac OS X Lion

Python library gevent, version 0.13.6 (the current version on PyPI) will not pip install on OS X Lion, Python 2.7 (and probably others.) It works fine on Snow Leopard. How can I get this library installed? Bonus points if it can be done using pip…
Jacob Lyles
  • 9,920
  • 7
  • 32
  • 30
43
votes
3 answers

In what way is grequests asynchronous?

I've been using the python requests library for some time, and recently had a need to make a request asynchronously, meaning I would like to send off the HTTP request, have my main thread continue to execute, and have a callback called when the…
cacois
  • 2,036
  • 2
  • 19
  • 19
42
votes
4 answers

gevent does not install properly on Ubuntu

I want to experiment with gevent, but after installing it I can't load any gevent module. The installation steps are: sudo apt-get install libevent-dev sudo pip install greenlet sudo pip install gevent The environment setup is Ubuntu 10.10 x86_64…
FabienB
  • 1,104
  • 2
  • 11
  • 22
38
votes
1 answer

Python requests with multithreading

I've been trying to build a scraper with multithreading functionality past two days. Somehow I still couldn't manage it. At first I tried regular multithreading approach with threading module but it wasn't faster than using a single thread. Later I…
krypt
  • 439
  • 1
  • 4
  • 13
36
votes
4 answers

Eventlet or gevent or Stackless + Twisted, Pylons, Django and SQL Alchemy

We're using Twisted extensively for apps requiring a great deal of asynchronous io. There are some cases where stuff is cpu bound instead and for that we spawn a pool of processes to do the work and have a system for managing these across multiple…
Khorkrak
  • 3,911
  • 2
  • 27
  • 37
35
votes
4 answers

Using Celery on processes and gevent in tasks at the same time

I'd like to use Celery as a queue for my tasks so my web app could enqueue a task, return a response and the task will be processed meanwhile / someday / ... I build a kind of API, so I don't know what sort of tasks will be there in advance - in…
Honza Javorek
  • 8,566
  • 8
  • 47
  • 66
32
votes
2 answers

aiogevent event loop "fails" to track greenlets

I recently stumbled onto a problem of mixing up gevent and asyncio-based code, because some synchronous libraries work just fine when I monkey-patch them with gevent.monkey.patch_all(). I found the aiogevent library, which seems to help by…
MaxLunar
  • 653
  • 6
  • 24
31
votes
3 answers

Python - Flask-SocketIO send message from thread: not always working

I am in the situation where I receive a message from the client. Within the function that handles that request (@socketio.on) I want to call a function where some heavy work is done. This should not result in blocking the main thread and the client…
Schnodderbalken
  • 3,257
  • 4
  • 34
  • 60
1
2 3
76 77