mirror of
https://github.com/kennethreitz/background.git
synced 2026-06-05 23:10:18 +00:00
+28
-8
@@ -10,15 +10,35 @@ Work in progress.
|
||||
Usage
|
||||
-----
|
||||
|
||||
import time
|
||||
::
|
||||
|
||||
import background
|
||||
import time
|
||||
|
||||
@background.task
|
||||
def work():
|
||||
# Do something expensive here.
|
||||
time.sleep(10)
|
||||
import background
|
||||
|
||||
@background.task
|
||||
def work():
|
||||
# Do something expensive here.
|
||||
time.sleep(10)
|
||||
|
||||
|
||||
for _ in range(100):
|
||||
work()
|
||||
for _ in range(100):
|
||||
work()
|
||||
|
||||
|
||||
Advanced Usage
|
||||
--------------
|
||||
|
||||
::
|
||||
|
||||
from background import Worker
|
||||
|
||||
worker = Worker(n=10, use_subprocess=True)
|
||||
|
||||
@worker.task
|
||||
def work():
|
||||
import time
|
||||
time.sleep(10)
|
||||
|
||||
for _ in range(100):
|
||||
work()
|
||||
Reference in New Issue
Block a user