File: grunter.py

package info (click to toggle)
uwsgi 2.0.31-4
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 6,740 kB
  • sloc: ansic: 87,072; python: 7,014; cpp: 1,133; java: 708; perl: 678; sh: 585; ruby: 555; makefile: 146; xml: 130; cs: 121; objc: 37; php: 28; erlang: 20; javascript: 11
file content (24 lines) | stat: -rw-r--r-- 612 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
import uwsgi
import time


from six.moves import range


def application(env, start_response):

    start_response('200 Ok', [('Content-Type', 'text/html')])

    yield "I am the worker %d<br/>" % uwsgi.worker_id()

    grunt = uwsgi.grunt()

    if grunt is None:
        print("worker %d detached" % uwsgi.worker_id())
    else:
        yield "And now i am the grunt with a fix worker id of %d<br/>" % uwsgi.worker_id()
        time.sleep(2)
        yield "Now, i will start a very slow task...<br/>"
        for i in range(1, 10):
            yield "waiting for %d seconds<br/>" % i
            time.sleep(i)