Added minimal version of watchdog
This commit is contained in:
parent
20ccc1460e
commit
5611ff2f93
26 changed files with 5195 additions and 0 deletions
41
Sublime/fl0w/watchdog/utils/event_backport.py
Normal file
41
Sublime/fl0w/watchdog/utils/event_backport.py
Normal file
|
@ -0,0 +1,41 @@
|
|||
#!/usr/bin/env python
|
||||
# -*- coding: utf-8 -*-
|
||||
# Backport of Event from py2.7 (method wait in py2.6 returns None)
|
||||
|
||||
from threading import Condition, Lock
|
||||
|
||||
|
||||
class Event(object):
|
||||
|
||||
def __init__(self,):
|
||||
self.__cond = Condition(Lock())
|
||||
self.__flag = False
|
||||
|
||||
def isSet(self):
|
||||
return self.__flag
|
||||
|
||||
is_set = isSet
|
||||
|
||||
def set(self):
|
||||
self.__cond.acquire()
|
||||
try:
|
||||
self.__flag = True
|
||||
self.__cond.notify_all()
|
||||
finally:
|
||||
self.__cond.release()
|
||||
|
||||
def clear(self):
|
||||
self.__cond.acquire()
|
||||
try:
|
||||
self.__flag = False
|
||||
finally:
|
||||
self.__cond.release()
|
||||
|
||||
def wait(self, timeout=None):
|
||||
self.__cond.acquire()
|
||||
try:
|
||||
if not self.__flag:
|
||||
self.__cond.wait(timeout)
|
||||
return self.__flag
|
||||
finally:
|
||||
self.__cond.release()
|
Reference in a new issue