python - bottle gevent and threading: gevent is only usable from a single thread -


i have python bottle application, uses threads. due fact i'm using monkey.patch, threads blocking app execution (a dialog box fired thread blocking bottle routes responding client, until dismissed.)

a little research here showed should use monkey patch without trying patch thread:

# patch python's threads greenlets gevent import monkey monkey.patch_all(thread=false) 

this not block on minimal example wrote.

but raises these errors on intensive use threads, methods threading.setevent()
error get:

c:\users\ieuser\downloadloft-localserver>python mainserver.py exception in thread thread-1: traceback (most recent call last):   file "c:\program files\downloadloft\python27\lib\threading.py", line 551, in _ _bootstrap_inner self.run()   file "c:\program files\downloadloft\python27\lib\threading.py", line 753, in r un self.finished.wait(self.interval)   file "c:\program files\downloadloft\python27\lib\threading.py", line 403, in w ait self.__cond.wait(timeout)   file "c:\program files\downloadloft\python27\lib\threading.py", line 262, in w ait _sleep(delay)   file "c:\users\admini~1\appdata\local\temp\easy_install-sch3hm\gevent-0.13.8-p y2.7-win32.egg.tmp\gevent\hub.py", line 79, in sleep switch_result = get_hub().switch()   file "c:\users\admini~1\appdata\local\temp\easy_install-sch3hm\gevent-0.13.8-p y2.7-win32.egg.tmp\gevent\hub.py", line 135, in get_hub raise notimplementederror('gevent usable single thread') notimplementederror: gevent usable single thread  bottle v0.12-dev server starting (using geventsocketioserver())... listening on http://localhost:8080/ hit ctrl-c quit.  exception in thread thread-2: traceback (most recent call last):   file "c:\program files\downloadloft\python27\lib\threading.py", line 551, in _ _bootstrap_inner self.run()   file "c:\program files\downloadloft\python27\lib\threading.py", line 753, in r un self.finished.wait(self.interval)   file "c:\program files\downloadloft\python27\lib\threading.py", line 403, in w ait self.__cond.wait(timeout)   file "c:\program files\downloadloft\python27\lib\threading.py", line 262, in w ait _sleep(delay)   file "c:\users\admini~1\appdata\local\temp\easy_install-sch3hm\gevent-0.13.8-p y2.7-win32.egg.tmp\gevent\hub.py", line 79, in sleep switch_result = get_hub().switch()   file "c:\users\admini~1\appdata\local\temp\easy_install-sch3hm\gevent-0.13.8-p y2.7-win32.egg.tmp\gevent\hub.py", line 135, in get_hub raise notimplementederror('gevent usable single thread') notimplementederror: gevent usable single thread 

is known issue gevent.monkeypatch? ideas?

bottle applications threaded, can't use gevent in function called in bottle routes.

to you, need speculate why use threads.

if it's accelerate bottle website, juste use cherrypy server :

pip install cherrypy  

(or dump cherrypy dir in current dir, it's pure python server)

then run bottle app way :

bottle.run(server='cherrypy') 

if it's because want make non blocking calls (such fetching urls) without blocking response, it's easy enought manually :

  • create queue object (it's special queue can filled , popped between threads).
  • create , run thread infinite while loop unpoping queue , doing actions every time.
  • when need non blocking call, push action queue , carry one.

Comments

Popular posts from this blog

c# - DetailsView in ASP.Net - How to add another column on the side/add a control in each row? -

javascript - firefox memory leak -

Trying to import CSV file to a SQL Server database using asp.net and c# - can't find what I'm missing -