Skip to content

Commit eb0efec

Browse files
authored
Removes eventlet in favor of signal package (#1341)
* Removes eventlet in favor of signal package Issues: Fixes #<issueid> Problem: The eventlet package was a good first attempt, but seems to have other issues that plague third party tools. Analysis: signal comes with Python and should not have the same issues Tests: functional * Fixes timeout possibly being a string * Removed traces of eventlet
1 parent 97f01e0 commit eb0efec

3 files changed

Lines changed: 14 additions & 20 deletions

File tree

f5/bigip/__init__.py

Lines changed: 12 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -24,16 +24,10 @@
2424
import urllib.parse as urlparse
2525

2626
try:
27-
import eventlet
28-
29-
# Workaround for bug 401 addressed here
30-
# https://github.com/eventlet/eventlet/issues/401#issuecomment-325015989
31-
#
32-
# This seems to happen on containers often.
33-
eventlet.hubs.get_hub()
34-
HAS_EVENTLET = True
27+
import signal
28+
HAS_SIGNAL = True
3529
except ImportError:
36-
HAS_EVENTLET = False
30+
HAS_SIGNAL = False
3731

3832
from f5.bigip.cm import Cm
3933
from f5.bigip.resource import PathElement
@@ -50,6 +44,10 @@
5044
from f5.sdk_exception import TimeoutError
5145

5246

47+
def timeout_handler(signum, frame):
48+
raise TimeoutError("Timed out waiting for response")
49+
50+
5351
class BaseManagement(PathElement):
5452
def __init__(self, hostname, username, password, **kwargs):
5553
self.args = self.parse_arguments(
@@ -115,13 +113,11 @@ def post_configuration_setup(self):
115113
def _get_tmos_version(self):
116114
connect = self._meta_data['bigip']._meta_data['icr_session']
117115
base_uri = self._meta_data['uri'] + 'tm/sys/'
118-
if HAS_EVENTLET:
119-
eventlet.monkey_patch()
120-
try:
121-
with eventlet.Timeout(self.args['timeout']):
122-
response = connect.get(base_uri)
123-
except eventlet.Timeout:
124-
raise TimeoutError("Timed out waiting for response")
116+
if HAS_SIGNAL:
117+
signal.signal(signal.SIGALRM, timeout_handler)
118+
signal.alarm(int(self.args['timeout']))
119+
response = connect.get(base_uri)
120+
signal.alarm(0)
125121
else:
126122
response = connect.get(base_uri)
127123
ver = response.json()

setup.cfg

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,4 @@ release = 1
33
requires = six>=1.9.0
44
six<2.0.0
55
f5-icontrol-rest>=1.3.0
6-
f5-icontrol-rest<2.0.0
7-
eventlet>=0.21.0
6+
f5-icontrol-rest<2.0.0

setup_requirements.txt

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,4 @@
22
six>=1.9.0
33
six<2.0.0
44
f5-icontrol-rest>=1.3.2
5-
f5-icontrol-rest<2.0.0
6-
eventlet>=0.21.0
5+
f5-icontrol-rest<2.0.0

0 commit comments

Comments
 (0)