Skip to content

Commit

Permalink
windows doesn't support well signals, just use a simple watcher for it.
Browse files Browse the repository at this point in the history
  • Loading branch information
benoitc committed May 8, 2011
1 parent 34ccf8f commit 6d99abc
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 3 deletions.
30 changes: 28 additions & 2 deletions couchapp/autopush/command.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,6 @@ def init_signals(self):
signal.signal(signal.SIGCHLD, self.handle_chld)

def signal(self, sig, frame):
print "got a signal"
if len(self.SIG_QUEUE) < 5:
self.SIG_QUEUE.append(sig)
else:
Expand Down Expand Up @@ -143,6 +142,28 @@ def run(self):
return -1
self.observer.join()

class WinCouchappWatcher(object):
def __init__(self, doc, dbs, update_delay=DEFAULT_UPDATE_DELAY,
noatomic=False):
self.doc_path = absolute_path(doc.docdir)
self.event_handler = CouchappEventHandler(doc, dbs,
update_delay=update_delay, noatomic=noatomic)
self.observer = Observer()
self.observer.schedule(self.event_handler,
self.doc_path, recursive=True)

def run(self):
log.info("Starting to listen changes in '%s'", self.doc_path)
self.observer.start()
try:
while True:
self.event_handler.maybe_update()
time.sleep(1)
except (SystemExit, KeyboardInterrupt):
self.observer.stop()
self.observer.join()


def autopush(conf, path, *args, **opts):
doc_path = None
dest = None
Expand All @@ -166,6 +187,11 @@ def autopush(conf, path, *args, **opts):
update_delay = int(opts.get('update_delay', DEFAULT_UPDATE_DELAY))
noatomic = opts.get('no_atomic', False)

watcher = CouchappWatcher(doc, dbs, update_delay=update_delay,
if sys.platform == "win32" or os.name == "nt":
watcher_class = WinCouchappWatcher
else:
watcher_class = CouchappWatcher

watcher = watcher_class(doc, dbs, update_delay=update_delay,
noatomic=noatomic)
watcher.run()
2 changes: 1 addition & 1 deletion resources/win32/README.build
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ Build steps:
3) In couchapp sources, execute following command lines:

python setup.py build -c mingw32
python setup.py py2exe -b
python setup.py py2exe -b 2

4) Copy add_path.exe to the dist directory

Expand Down

0 comments on commit 6d99abc

Please sign in to comment.