Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit7a50383

Browse files
kvapkelvich
authored andcommitted
Prevent the test from failing at the start if 20 seconds were not enough.
1 parent5453400 commit7a50383

File tree

1 file changed

+16
-5
lines changed

1 file changed

+16
-5
lines changed

‎tests2/client2.py

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ def __init__(self, name):
2020
defclear_values(self):
2121
self.max_latency=0.0
2222
self.finish= {}
23-
23+
2424
defstart_tx(self):
2525
self.start_time=datetime.datetime.now()
2626

@@ -34,7 +34,7 @@ def finish_tx(self, name):
3434
self.finish[name]=1
3535
else:
3636
self.finish[name]+=1
37-
37+
3838
defas_dict(self):
3939
return {
4040
'running_latency': (datetime.datetime.now()-self.start_time).total_seconds(),
@@ -43,13 +43,24 @@ def as_dict(self):
4343
'finish':copy.deepcopy(self.finish)
4444
}
4545

46+
defkeep_trying(tries,delay,method,name,*args,**kwargs):
47+
fortinrange(tries):
48+
try:
49+
returnmethod(*args,**kwargs)
50+
exceptExceptionase:
51+
ift==tries-1:
52+
raiseException("%s failed all %d tries"% (name,tries))frome
53+
print("%s failed [%d of %d]: %s"% (name,t+1,tries,str(e)))
54+
time.sleep(delay)
55+
raiseException("this should not happen")
56+
4657
classMtmClient(object):
4758

4859
def__init__(self,dsns,n_accounts=100000):
4960
self.n_accounts=n_accounts
5061
self.dsns=dsns
5162
self.aggregates= {}
52-
self.initdb()
63+
keep_trying(40,1,self.initdb,'self.initdb')
5364
self.running=True
5465
self.nodes_state_fields= ["id","disabled","disconnected","catchUp","slotLag",
5566
"avgTransDelay","lastStatusChange","oldestSnapshot","SenderPid",
@@ -173,7 +184,7 @@ def run(self):
173184
asyncio.async(self.status())
174185

175186
self.loop.run_forever()
176-
187+
177188
defbgrun(self):
178189
print('Starting evloop in different process');
179190
self.parent_pipe,self.child_pipe=aioprocessing.AioPipe()
@@ -187,7 +198,7 @@ def get_status(self):
187198
resp=self.parent_pipe.recv()
188199
print('test: got status response')
189200
returnresp
190-
201+
191202
defstop(self):
192203
self.running=False
193204
self.evloop_process.terminate()

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp