Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Lock not released when timeout occurs #40

Open
erics465 opened this issue Sep 17, 2019 · 0 comments · May be fixed by #39
Open

Lock not released when timeout occurs #40

erics465 opened this issue Sep 17, 2019 · 0 comments · May be fixed by #39

Comments

@erics465
Copy link

ucscsdk version: 0.9.0.1
Python version: 3.7.3
Operating System: Debian 10

Description

I was testing error handling with the ucscsdk, especially timeouts when logging in with a handle to UCSC instance. The following code should throw a timeout exception after the default timeout has been exceeded. However, only the first time a handle is being created and times out, the exception is being thrown. After that, further handles just hang forever at the login() method. Digging down the source, it seems that a lock is not released in ucscsession.py when a timeout (or connection refused, etc.) exception occurs (on line 250).

What I Did

Minimal code:

    try:
       handle = UcscHandle(self.creds['hostname'], self.creds['username'], self.creds['password']))
       if handle.last_update_time is None:
           handle.login()
    except Exception as e:
        print(e)
        return

Stacktrace of timeout

Traceback (most recent call last):
  File "/mnt/hgfs/ucsc-exporter/modules/main_collector.py", line 100, in collect
    self.handles[x].login()
  File "/home/eric/.local/lib/python3.7/site-packages/ucscsdk/ucschandle.py", line 117, in login
    return self._login(auto_refresh, force)
  File "/home/eric/.local/lib/python3.7/site-packages/ucscsdk/ucscsession.py", line 475, in _login
    response = self.post_elem(elem)
  File "/home/eric/.local/lib/python3.7/site-packages/ucscsdk/ucscsession.py", line 250, in post_elem
    response_str = self.post_xml(xml_str, dme=dme)
  File "/home/eric/.local/lib/python3.7/site-packages/ucscsdk/ucscsession.py", line 203, in post_xml
    response_str = self.post(uri=ucsm_uri, data=xml_str, read=read)
  File "/home/eric/.local/lib/python3.7/site-packages/ucscsdk/ucscsession.py", line 185, in post
    response = self.__driver.post(uri=uri, data=data, read=read)
  File "/home/eric/.local/lib/python3.7/site-packages/ucscsdk/ucscdriver.py", line 180, in post
    response = opener.open(request, timeout=10)
  File "/usr/lib/python3.7/urllib/request.py", line 525, in open
    response = self._open(req, data)
  File "/usr/lib/python3.7/urllib/request.py", line 543, in _open
    '_open', req)
  File "/usr/lib/python3.7/urllib/request.py", line 503, in _call_chain
    result = func(*args)
  File "/home/eric/.local/lib/python3.7/site-packages/ucscsdk/ucscdriver.py", line 42, in https_open
    return self.do_open(TLS1Connection, req)
  File "/usr/lib/python3.7/urllib/request.py", line 1319, in do_open
    raise URLError(err)
urllib.error.URLError: <urlopen error timed out>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant