FAQ Database Discussion Community


Gevent vs sync processing for scanning, why are they approximately the same speed?

python,multithreading,gevent
def cn(host, port): try: conn = socket.socket(socket.AF_INET, socket.SOCK_STREAM) conn.connect((host, port)) print '[+]%d/tcp open' % port conn.close() except: pass #print '[-]%d/tcp closed' % port def ge(): st = time.time() threads = [gevent.spawn(cn, '127.0.0.1', i) for i in xrange(1000)] gevent.joinall(threads) print "using gevent - " + str(time.time() - st) def ss(): st...

Can we use gevent.sleep() for precise timings?

python,real-time,embedded-linux,gevent
Can we use gevent.sleep() anywhere in our application or gevent.monkey.patch_time() on any third party libraries without an issue, especially precise timings takes place? For example, some libraries use time.sleep() function in order to measure a couple of microseconds that is used to control an embedded (dot matrix LCD and such)...

gevent / requests hangs while making lots of head requests

python,urllib2,python-requests,gevent,grequests
I need to make 100k head requests, and I'm using gevent on top of requests. My code runs for a while, but then eventually hangs. I'm not sure why it's hanging, or whether it's hanging inside requests or gevent. I'm using the timeout argument inside both requests and gevent. Please...

Python select epoll in Gevent

python,gevent,epoll
I'm working on GPIO stuff in Python, need to register the fd on epoll, since gevent monkey patched the python select library, there will not be select.epoll if monkey.patch_all(select=True), so here comes two questions: Will be consequence that the monkey.patch_all(select=False)? Or does Gevent provide its own epoll register stuff? Thank...

Close TCP socket in the Greenlet only after successful transfer

python,sockets,asynchronous,gevent
I'm trying here to close my TCP socket only after all data is successfully transferred: from gevent import monkey; monkey.patch_all() import gevent import socket host = "127.0.0.1" port = 8888 line_term = "\r\n" login_str = ["Action: Login", "ActionID: 1", "Username: ami", "Secret: password", ] def login(login_str): conn = socket.create_connection([host, port])...

Errno 13 Permission denied using Gunicorn

gunicorn,gevent
I'm running django on Digital Ocean with gunicorn and nginx. Gunicorn for serving the django and nginx for static files. Upon uploading a file via website, I cant save to a folder in /home directory. I get [Errno 13] Permission denied. Please, how do I make the webserver to be...

Python error: execute cannot be used while an asynchronous query is underway

python,psycopg2,gevent
How do I prevent the error “ProgrammingError: execute cannot be used while an asynchronous query is underway”? From the docs it says that I should use psycopg2.extras.wait_select if I’m using a coroutine support like gevent., but I’m still get that error when I’m using it. I’ve isolated the error I’m...

I can't install Gevent

python,python-2.7,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 work in python 2.6...