Skip to content

Commit 9c68a97

Browse files
committed
Fix connection-refused race condition when spawning tasks
Signed-off-by: Plamen Dimitrov <[email protected]>
1 parent c93f18e commit 9c68a97

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

avocado/core/nrunner/task.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
import json
33
import socket
44
import tempfile
5+
import time
56
from uuid import uuid1
67

78
from avocado.core.nrunner.runnable import (
@@ -41,7 +42,16 @@ def post(self, status):
4142
host, port = self.uri.split(':')
4243
port = int(port)
4344
if self.connection is None:
44-
self.connection = socket.create_connection((host, port))
45+
for _ in range(30):
46+
try:
47+
self.connection = socket.create_connection((host, port))
48+
break
49+
except ConnectionRefusedError as error:
50+
# TODO: should we at least provide some logging here?
51+
#logging.error(error)
52+
time.sleep(1)
53+
else:
54+
raise error
4555
else:
4656
if self.connection is None:
4757
self.connection = socket.socket(socket.AF_UNIX,

0 commit comments

Comments
 (0)