forked from twisted-infra/twisted-benchmarks
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdeferred_callback_chains.py
More file actions
34 lines (25 loc) · 825 Bytes
/
deferred_callback_chains.py
File metadata and controls
34 lines (25 loc) · 825 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
from twisted.internet.defer import succeed
from benchlib import Client, driver
class Client(Client):
def _request(self):
d = succeed('result')
def cbRaiseErr(result):
raise Exception('boom!')
d.addCallback(cbRaiseErr)
def ebHandleErr(failure):
failure.trap(Exception)
raise Exception('lesser boom!')
d.addErrback(ebHandleErr)
def swallowErr(failure):
return None
d.addBoth(swallowErr)
self._reactor.callLater(0.0, self._continue, None)
def main(reactor, duration):
concurrency = 10
client = Client(reactor)
d = client.run(concurrency, duration)
return d
if __name__ == '__main__':
import sys
import deferred_callback_chains
driver(deferred_callback_chains.main, sys.argv)