1917
|
1 #!bin/python
|
|
2 from run_local import log
|
|
3 from twisted.internet import reactor, task, defer
|
|
4 from rdflib import URIRef, Literal
|
|
5 from twisted.internet.defer import ensureDeferred
|
|
6 from rdfdb.syncedgraph import SyncedGraph
|
|
7 import time, logging
|
|
8
|
|
9 from light9 import networking, showconfig
|
|
10 from light9.namespaces import L9
|
|
11
|
1927
|
12
|
1917
|
13 class BusyClient:
|
1927
|
14
|
1917
|
15 def __init__(self, subj, rate):
|
|
16 self.subj = subj
|
|
17 self.rate = rate
|
1927
|
18
|
1917
|
19 self.graph = SyncedGraph(networking.rdfdb.url, "collector")
|
|
20 self.graph.initiallySynced.addCallback(self.go)
|
1927
|
21
|
1917
|
22 def go(self, _):
|
|
23 task.LoopingCall(self.loop).start(1 / self.rate)
|
|
24
|
|
25 def loop(self):
|
|
26 self.graph.patchObject(showconfig.showUri() + '/loadTestContext',
|
|
27 subject=self.subj,
|
1927
|
28 predicate=L9['time'],
|
|
29 newObject=Literal(str(time.time())))
|
|
30
|
1917
|
31
|
|
32 def main():
|
|
33 log.setLevel(logging.INFO)
|
|
34
|
|
35 clients = [BusyClient(L9['loadTest_%d' % i], 20) for i in range(10)]
|
|
36 reactor.run()
|
1927
|
37
|
|
38
|
1917
|
39 if __name__ == "__main__":
|
|
40 main()
|