File tree Expand file tree Collapse file tree 1 file changed +18
-0
lines changed Expand file tree Collapse file tree 1 file changed +18
-0
lines changed Original file line number Diff line number Diff line change 4
4
5
5
import os
6
6
import pytest
7
+ import psutil
8
+ import gevent
7
9
from gevent import Greenlet
8
10
9
11
from raiden .app import App
14
16
from raiden .tests .utils .apitestcontext import ApiTestContext
15
17
16
18
19
+ def wait_for_listening_port (port_number , tries = 10 , sleep = 0.1 ):
20
+ for _ in range (tries ):
21
+ gevent .sleep (sleep )
22
+ connections = psutil .net_connections ()
23
+ for conn in connections :
24
+ if conn .status == 'LISTEN' and conn .laddr [1 ] == port_number :
25
+ return
26
+
27
+ raise RuntimeError ('{port} is not bound' .format (port_number ))
28
+
29
+
17
30
# TODO: Figure out why this fixture can't work as session scoped
18
31
# What happens is that after one test is done, in the next one
19
32
# the server is no longer running even though the teardown has not
@@ -34,6 +47,11 @@ def api_backend(rest_api_port_number):
34
47
use_evalex = False ,
35
48
)
36
49
50
+ # Fixes flaky test, were requests are done prior to the server initializing
51
+ # the listening socket.
52
+ # https://github.com/raiden-network/raiden/issues/389#issuecomment-305551563
53
+ wait_for_listening_port (rest_api_port_number )
54
+
37
55
yield api_server , rest_api
38
56
39
57
server .kill (block = True , timeout = 10 )
You can’t perform that action at this time.
0 commit comments