Skip to content
Browse files

Disable gevent

  • Loading branch information...
1 parent e234484 commit a8a1ceeeb8953ab22eb58ff02cdd3c2e2264e92f Adam DePrince committed Mar 4, 2013
Showing with 33 additions and 5 deletions.
  1. +33 −5 autosync/daemon.py
View
38 autosync/daemon.py
@@ -1,9 +1,36 @@
+
+use_gevent = False
+
import select
from pyinotify import WatchManager, Notifier, ThreadedNotifier, EventsCodes, ProcessEvent
-import gevent
-from gevent import queue, spawn, joinall
-from gevent.queue import Queue
-from gevent.monkey import patch_all
+
+if use_gevent:
+ import gevent
+ from gevent import spawn, joinall
+ from gevent.queue import Queue
+ from gevent.monkey import patch_all
+else:
+ import thread
+ from Queue import Queue
+ # Duplicate gevent's semantics with thread
+ def spawn(func, *args, **kwargs):
+ def join_emulator(func, lock, *args, **kwargs):
+ func(*args, **kwargs)
+ lock.release()
+
+ lock = thread.allocate_lock()
+ lock.acquire(True)
+
+ args = (lock,) + tuple(args)
+ return thread.start_new_thread(func, args, kwargs)
+
+ def joinall(locks):
+ for lock in locks:
+ lock.acquire(True)
+ lock.release(True)
+
+
+
import autosync
import autosync.actors
import autosync.actors.s3
@@ -12,7 +39,8 @@
import gflags
-patch_all(select=False)
+if use_gevent:
+ patch_all(select=False)
FLAGS = gflags.FLAGS

0 comments on commit a8a1cee

Please sign in to comment.
Something went wrong with that request. Please try again.