/
opt
/
alt
/
python33
/
lib64
/
python3.3
/
/opt/alt/python33/lib64/python3.3
mkdir
upload
Name
Size
Mode
Actions
collections/
-
0755
rm
concurrent/
-
0755
rm
config-3.3m/
-
0755
rm
ctypes/
-
0755
rm
curses/
-
0755
rm
dbm/
-
0755
rm
distutils/
-
0755
rm
email/
-
0755
rm
encodings/
-
0755
rm
html/
-
0755
rm
http/
-
0755
rm
idlelib/
-
0755
rm
importlib/
-
0755
rm
json/
-
0755
rm
lib-dynload/
-
0755
rm
lib2to3/
-
0755
rm
logging/
-
0755
rm
multiprocessing/
-
0755
rm
plat-linux/
-
0755
rm
pydoc_data/
-
0755
rm
site-packages/
-
0755
rm
sqlite3/
-
0755
rm
test/
-
0755
rm
unittest/
-
0755
rm
urllib/
-
0755
rm
venv/
-
0755
rm
wsgiref/
-
0755
rm
xml/
-
0755
rm
xmlrpc/
-
0755
rm
__pycache__/
-
0755
rm
abc.py
8057
0644
edit
dl
rm
aifc.py
31054
0644
edit
dl
rm
antigravity.py
475
0644
edit
dl
rm
argparse.py
89069
0644
edit
dl
rm
ast.py
12142
0644
edit
dl
rm
asynchat.py
11588
0644
edit
dl
rm
asyncore.py
20753
0644
edit
dl
rm
base64.py
13986
0755
edit
dl
rm
bdb.py
21894
0644
edit
dl
rm
binhex.py
13708
0644
edit
dl
rm
bisect.py
2595
0644
edit
dl
rm
bz2.py
18473
0644
edit
dl
rm
calendar.py
22940
0644
edit
dl
rm
cgi.py
35554
0755
edit
dl
rm
cgitb.py
12041
0644
edit
dl
rm
chunk.py
5377
0644
edit
dl
rm
cmd.py
14860
0644
edit
dl
rm
code.py
10030
0644
edit
dl
rm
codecs.py
35956
0644
edit
dl
rm
codeop.py
5994
0644
edit
dl
rm
colorsys.py
3691
0644
edit
dl
rm
compileall.py
9743
0644
edit
dl
rm
configparser.py
49437
0644
edit
dl
rm
contextlib.py
9125
0644
edit
dl
rm
copy.py
8991
0644
edit
dl
rm
copyreg.py
6611
0644
edit
dl
rm
cProfile.py
6361
0755
edit
dl
rm
crypt.py
1879
0644
edit
dl
rm
csv.py
16185
0644
edit
dl
rm
datetime.py
74954
0644
edit
dl
rm
decimal.py
228558
0644
edit
dl
rm
difflib.py
82519
0644
edit
dl
rm
dis.py
10134
0644
edit
dl
rm
doctest.py
102933
0644
edit
dl
rm
dummy_threading.py
2815
0644
edit
dl
rm
filecmp.py
9597
0644
edit
dl
rm
fileinput.py
14256
0644
edit
dl
rm
fnmatch.py
3163
0644
edit
dl
rm
formatter.py
14930
0644
edit
dl
rm
fractions.py
23033
0644
edit
dl
rm
ftplib.py
40253
0644
edit
dl
rm
functools.py
13596
0644
edit
dl
rm
genericpath.py
3093
0644
edit
dl
rm
getopt.py
7488
0644
edit
dl
rm
getpass.py
5793
0644
edit
dl
rm
gettext.py
20637
0644
edit
dl
rm
glob.py
2838
0644
edit
dl
rm
gzip.py
24403
0644
edit
dl
rm
hashlib.py
6193
0644
edit
dl
rm
heapq.py
17997
0644
edit
dl
rm
hmac.py
4440
0644
edit
dl
rm
imaplib.py
50111
0644
edit
dl
rm
imghdr.py
3528
0644
edit
dl
rm
imp.py
9727
0644
edit
dl
rm
inspect.py
78960
0644
edit
dl
rm
io.py
3280
0644
edit
dl
rm
ipaddress.py
70303
0644
edit
dl
rm
keyword.py
2060
0755
edit
dl
rm
linecache.py
3864
0644
edit
dl
rm
locale.py
93215
0644
edit
dl
rm
lzma.py
17454
0644
edit
dl
rm
macpath.py
5617
0644
edit
dl
rm
macurl2path.py
2732
0644
edit
dl
rm
mailbox.py
79093
0644
edit
dl
rm
mailcap.py
7437
0644
edit
dl
rm
mimetypes.py
20735
0644
edit
dl
rm
modulefinder.py
23198
0644
edit
dl
rm
netrc.py
5747
0644
edit
dl
rm
nntplib.py
42786
0644
edit
dl
rm
ntpath.py
20437
0644
edit
dl
rm
nturl2path.py
2396
0644
edit
dl
rm
numbers.py
10398
0644
edit
dl
rm
opcode.py
5098
0644
edit
dl
rm
optparse.py
60346
0644
edit
dl
rm
os.py
34779
0644
edit
dl
rm
os2emxpath.py
4659
0644
edit
dl
rm
pdb.py
60653
0755
edit
dl
rm
pickle.py
47858
0644
edit
dl
rm
pickletools.py
81349
0644
edit
dl
rm
pipes.py
8916
0644
edit
dl
rm
pkgutil.py
21539
0644
edit
dl
rm
platform.py
50742
0755
edit
dl
rm
plistlib.py
14777
0644
edit
dl
rm
poplib.py
11372
0644
edit
dl
rm
posixpath.py
14254
0644
edit
dl
rm
pprint.py
12700
0644
edit
dl
rm
profile.py
21448
0755
edit
dl
rm
pstats.py
26372
0644
edit
dl
rm
pty.py
5055
0644
edit
dl
rm
pyclbr.py
13438
0644
edit
dl
rm
pydoc.py
101644
0755
edit
dl
rm
py_compile.py
6717
0644
edit
dl
rm
queue.py
8835
0644
edit
dl
rm
quopri.py
7315
0755
edit
dl
rm
random.py
25660
0644
edit
dl
rm
re.py
14973
0644
edit
dl
rm
reprlib.py
5110
0644
edit
dl
rm
rlcompleter.py
5526
0644
edit
dl
rm
runpy.py
10413
0644
edit
dl
rm
sched.py
6399
0644
edit
dl
rm
shelve.py
8243
0644
edit
dl
rm
shlex.py
11502
0644
edit
dl
rm
shutil.py
39147
0644
edit
dl
rm
site.py
21971
0644
edit
dl
rm
smtpd.py
30207
0755
edit
dl
rm
smtplib.py
38021
0755
edit
dl
rm
sndhdr.py
6219
0644
edit
dl
rm
socket.py
14913
0644
edit
dl
rm
socketserver.py
24196
0644
edit
dl
rm
sre_compile.py
16345
0644
edit
dl
rm
sre_constants.py
7231
0644
edit
dl
rm
sre_parse.py
30212
0644
edit
dl
rm
ssl.py
24478
0644
edit
dl
rm
stat.py
4304
0644
edit
dl
rm
string.py
9410
0644
edit
dl
rm
stringprep.py
12917
0644
edit
dl
rm
struct.py
238
0644
edit
dl
rm
subprocess.py
67578
0644
edit
dl
rm
sunau.py
17523
0644
edit
dl
rm
symbol.py
2051
0755
edit
dl
rm
symtable.py
7383
0644
edit
dl
rm
sysconfig.py
25174
0644
edit
dl
rm
tabnanny.py
11410
0755
edit
dl
rm
tarfile.py
88864
0755
edit
dl
rm
telnetlib.py
27349
0644
edit
dl
rm
tempfile.py
23013
0644
edit
dl
rm
textwrap.py
16488
0644
edit
dl
rm
this.py
1003
0644
edit
dl
rm
threading.py
45641
0644
edit
dl
rm
timeit.py
12395
0755
edit
dl
rm
token.py
3034
0644
edit
dl
rm
tokenize.py
24876
0644
edit
dl
rm
trace.py
31487
0755
edit
dl
rm
traceback.py
11982
0644
edit
dl
rm
tty.py
879
0644
edit
dl
rm
types.py
3167
0644
edit
dl
rm
uu.py
6766
0755
edit
dl
rm
uuid.py
22349
0644
edit
dl
rm
warnings.py
13825
0644
edit
dl
rm
wave.py
18579
0644
edit
dl
rm
weakref.py
11495
0644
edit
dl
rm
webbrowser.py
22913
0755
edit
dl
rm
xdrlib.py
5381
0644
edit
dl
rm
zipfile.py
66424
0644
edit
dl
rm
_compat_pickle.py
4338
0644
edit
dl
rm
_dummy_thread.py
4769
0644
edit
dl
rm
_markupbase.py
14598
0644
edit
dl
rm
_osx_support.py
18855
0644
edit
dl
rm
_pyio.py
72905
0644
edit
dl
rm
_strptime.py
21674
0644
edit
dl
rm
_sysconfigdata.py
21056
0644
edit
dl
rm
_threading_local.py
7410
0644
edit
dl
rm
_weakrefset.py
5705
0644
edit
dl
rm
__future__.py
4584
0644
edit
dl
rm
__phello__.foo.py
64
0644
edit
dl
rm
Edit:
/opt/alt/python33/lib64/python3.3/sched.py
(6399B)
"""A generally useful event scheduler class. Each instance of this class manages its own queue. No multi-threading is implied; you are supposed to hack that yourself, or use a single instance per application. Each instance is parametrized with two functions, one that is supposed to return the current time, one that is supposed to implement a delay. You can implement real-time scheduling by substituting time and sleep from built-in module time, or you can implement simulated time by writing your own functions. This can also be used to integrate scheduling with STDWIN events; the delay function is allowed to modify the queue. Time can be expressed as integers or floating point numbers, as long as it is consistent. Events are specified by tuples (time, priority, action, argument, kwargs). As in UNIX, lower priority numbers mean higher priority; in this way the queue can be maintained as a priority queue. Execution of the event means calling the action function, passing it the argument sequence in "argument" (remember that in Python, multiple function arguments are be packed in a sequence) and keyword parameters in "kwargs". The action function may be an instance method so it has another way to reference private data (besides global variables). """ # XXX The timefunc and delayfunc should have been defined as methods # XXX so you can define new kinds of schedulers using subclassing # XXX instead of having to define a module or class just to hold # XXX the global state of your particular time and delay functions. import time import heapq from collections import namedtuple try: import threading except ImportError: import dummy_threading as threading try: from time import monotonic as _time except ImportError: from time import time as _time __all__ = ["scheduler"] class Event(namedtuple('Event', 'time, priority, action, argument, kwargs')): def __eq__(s, o): return (s.time, s.priority) == (o.time, o.priority) def __ne__(s, o): return (s.time, s.priority) != (o.time, o.priority) def __lt__(s, o): return (s.time, s.priority) < (o.time, o.priority) def __le__(s, o): return (s.time, s.priority) <= (o.time, o.priority) def __gt__(s, o): return (s.time, s.priority) > (o.time, o.priority) def __ge__(s, o): return (s.time, s.priority) >= (o.time, o.priority) _sentinel = object() class scheduler: def __init__(self, timefunc=_time, delayfunc=time.sleep): """Initialize a new instance, passing the time and delay functions""" self._queue = [] self._lock = threading.RLock() self.timefunc = timefunc self.delayfunc = delayfunc def enterabs(self, time, priority, action, argument=(), kwargs=_sentinel): """Enter a new event in the queue at an absolute time. Returns an ID for the event which can be used to remove it, if necessary. """ if kwargs is _sentinel: kwargs = {} with self._lock: event = Event(time, priority, action, argument, kwargs) heapq.heappush(self._queue, event) return event # The ID def enter(self, delay, priority, action, argument=(), kwargs=_sentinel): """A variant that specifies the time as a relative time. This is actually the more commonly used interface. """ with self._lock: time = self.timefunc() + delay return self.enterabs(time, priority, action, argument, kwargs) def cancel(self, event): """Remove an event from the queue. This must be presented the ID as returned by enter(). If the event is not in the queue, this raises ValueError. """ with self._lock: self._queue.remove(event) heapq.heapify(self._queue) def empty(self): """Check whether the queue is empty.""" with self._lock: return not self._queue def run(self, blocking=True): """Execute events until the queue is empty. If blocking is False executes the scheduled events due to expire soonest (if any) and then return the deadline of the next scheduled call in the scheduler. When there is a positive delay until the first event, the delay function is called and the event is left in the queue; otherwise, the event is removed from the queue and executed (its action function is called, passing it the argument). If the delay function returns prematurely, it is simply restarted. It is legal for both the delay function and the action function to modify the queue or to raise an exception; exceptions are not caught but the scheduler's state remains well-defined so run() may be called again. A questionable hack is added to allow other threads to run: just after an event is executed, a delay of 0 is executed, to avoid monopolizing the CPU when other threads are also runnable. """ # localize variable access to minimize overhead # and to improve thread safety lock = self._lock q = self._queue delayfunc = self.delayfunc timefunc = self.timefunc pop = heapq.heappop while True: with lock: if not q: break time, priority, action, argument, kwargs = q[0] now = timefunc() if time > now: delay = True else: delay = False pop(q) if delay: if not blocking: return time - now delayfunc(time - now) else: action(*argument, **kwargs) delayfunc(0) # Let other threads run @property def queue(self): """An ordered list of upcoming events. Events are named tuples with fields for: time, priority, action, arguments, kwargs """ # Use heapq to sort the queue rather than using 'sorted(self._queue)'. # With heapq, two events scheduled at the same time will show in # the actual order they would be retrieved. with self._lock: events = self._queue[:] return list(map(heapq.heappop, [events]*len(events)))
Save
cmd:
run