Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 104 lines (74 sloc) 2.499 kb
984df3bc »
2011-06-15 added signal sending in uwsgicc
1 import uwsgi
2
8cc73991 »
2011-06-16 added checks for decorators
3 if uwsgi.masterpid() == 0:
4 raise Exception("you have to enable the uWSGI master process to use this module")
5
6 if uwsgi.opt.get('lazy'):
7 raise Exception("uWSGI lazy mode is not supporte by this module")
8
750bbd64 »
2011-07-01 new option --import, new api function uwsgi.signal_registered
9 spooler_functions = {}
10
11 def get_free_signal():
12 for signum in xrange(0, 256):
13 if not uwsgi.signal_registered(signum):
14 return signum
15
16 raise Exception("No free uwsgi signal available")
17
18 def manage_spool_request(vars):
19 spooler_functions[vars['ud_spool_func']](vars)
20 return spooler_functions[vars['ud_spool_func']].ret
21
22 uwsgi.spooler = manage_spool_request
23
24
25 class spool(object):
26
27 def spool(self, *args, **kwargs):
28 self.f.ret = uwsgi.SPOOL_OK
29 return uwsgi.spool(ud_spool_func=self.f.__name__)
30
31 def __init__(self, f):
32 if not uwsgi.spooler_pid:
33 raise Exception("you have to enable the uWSGI spooler to use the @spool decorator")
34 spooler_functions[f.__name__] = f
35 f.spool = self.spool
36 self.f = f
37
38 class spoolforever(spool):
39
40 def spool(self, *args, **kwargs):
41 self.f.ret = uwsgi.SPOOL_RETRY
42 return uwsgi.spool(ud_spool_func=self.f.__name__)
43
44
984df3bc »
2011-06-15 added signal sending in uwsgicc
45 class rpc(object):
46
47 def __init__(self, name):
48 self.name = name
49
50 def __call__(self, f):
51 uwsgi.register_rpc(self.name, f)
52 return f
53
54 class signal(object):
55
56 def __init__(self, num):
57 self.num = num
58
59 def __call__(self, f):
60 uwsgi.register_signal(self.num, "", f)
61 return f
ecce74ad »
2011-06-16 less verbose logging in inotify
62
63 class timer(object):
64
750bbd64 »
2011-07-01 new option --import, new api function uwsgi.signal_registered
65 def __init__(self, secs, num=None):
66 if num:
67 self.num = num
68 else:
69 self.num = get_free_signal()
ecce74ad »
2011-06-16 less verbose logging in inotify
70 self.secs = secs
71
72 def __call__(self, f):
73 uwsgi.register_signal(self.num, "", f)
74 uwsgi.add_timer(self.num, self.secs)
75 return f
76
77 class rbtimer(object):
78
750bbd64 »
2011-07-01 new option --import, new api function uwsgi.signal_registered
79 def __init__(self, secs, num=None):
80 if num:
81 self.num = num
82 else:
83 self.num = get_free_signal()
ecce74ad »
2011-06-16 less verbose logging in inotify
84 self.secs = secs
85
86 def __call__(self, f):
87 uwsgi.register_signal(self.num, "", f)
88 uwsgi.add_rb_timer(self.num, self.secs)
89 return f
90
91 class filemon(object):
92
750bbd64 »
2011-07-01 new option --import, new api function uwsgi.signal_registered
93 def __init__(self, fsobj, num=None):
94 if num:
95 self.num = num
96 else:
97 self.num = get_free_signal()
ecce74ad »
2011-06-16 less verbose logging in inotify
98 self.fsobj = fsobj
99
100 def __call__(self, f):
101 uwsgi.register_signal(self.num, "", f)
102 uwsgi.add_file_monitor(self.num, self.fsobj)
103 return f
Something went wrong with that request. Please try again.