[pytango] 15/26: Merge branch 'threadpool_with_exception_fix' into 'master'

Sandor Bodo-Merle sbodomerle-guest at moszumanska.debian.org
Thu Sep 28 19:16:14 UTC 2017


This is an automated email from the git hooks/post-receive script.

sbodomerle-guest pushed a commit to annotated tag v8.1.8
in repository pytango.

commit 9229071fb1370b301636cb00ae5ac605ff935125
Merge: c7b64b4 edff059
Author: Jose Tiago Coutinho Macara <tiago.coutinho at esrf.fr>
Date:   Mon Oct 5 10:10:52 2015 +0200

    Merge branch 'threadpool_with_exception_fix' into 'master'
    
    Fix gevent threadpool to be able to raise exceptions
    
    Hi,
    
    We work together with Matias and found that the gevent threadpool do not manage very well exceptions raised by the function called.
    
    As result we can't catch anything and the exception is printed to the console by the threadpool. Here bellow we can see that the 'constructor' returns ```None``` which means the exception can't be catched.
    
    ```
    $ python -c "import PyTango.gevent; print '--->', PyTango.gevent.DeviceProxy('#')"
    
    Traceback (most recent call last):
      File "/usr/local/lib/python2.7/dist-packages/gevent-1.0rc3-py2.7-linux-x86_64.egg/gevent/threadpool.py", line 193, in _worker
        value = func(*args, **kwargs)
      File "/home/valls/.local/lib/python2.7/site-packages/PyTango/device_proxy.py", line 129, in __DeviceProxy__init__
        return DeviceProxy.__init_orig__(self, *args, **kwargs)
    WrongNameSyntax: DevFailed[
    DevError[
        desc =  modifier is an unsupported db modifier
      origin = DeviceProxy::parse_name()
      reason = API_UnsupportedDBaseModifier
    severity = ERR]
    ]
    (<ThreadPool at 0x7f5a19f03c10 0/1/10>, <class 'PyTango._PyTango.DeviceProxy'>) failed with WrongNameSyntax
    
    ---> None
    ```
    
    We fixed the tango gevent module to wrap the exception and raise it again when called want to get the result.
    
    This patch is done using the ```tango_gevent.spawn``` function. But this function was cut through by the function ```get_submitter``` which was not returning the ```tango_gevent.spawn``` but the threadpool it-self. The second patch fix it. Another solution for this issue can be the injection of a hacked version of ```threadpool.spawn``` method which is able to manage the wrapping.
    
    As result, exceptions are now reachable, and its traceback is much more useful.
    
    ```
    $ python -c "import PyTango.gevent; print '--->', PyTango.gevent.DeviceProxy('#')"
    
    --->
    Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "/home/valls/.local/lib/python2.7/site-packages/PyTango/device_proxy.py", line 100, in get_device_proxy
        return result(d, green_mode, wait=wait, timeout=timeout)
      File "/home/valls/.local/lib/python2.7/site-packages/PyTango/green.py", line 111, in result
        return value.get(timeout=timeout)
      File "/home/valls/.local/lib/python2.7/site-packages/PyTango/tango_gevent.py", line 38, in __call__
        return func(*args, **kwargs)
      File "/home/valls/.local/lib/python2.7/site-packages/PyTango/device_proxy.py", line 129, in __DeviceProxy__init__
        return DeviceProxy.__init_orig__(self, *args, **kwargs)
    PyTango.WrongNameSyntax: DevFailed[
    DevError[
        desc =  modifier is an unsupported db modifier
      origin = DeviceProxy::parse_name()
      reason = API_UnsupportedDBaseModifier
    severity = ERR]
    ]
    ```
    
    See merge request !5

 src/boost/python/green.py        |  5 +----
 src/boost/python/tango_gevent.py | 47 +++++++++++++++++++++++++++++++++++++---
 2 files changed, 45 insertions(+), 7 deletions(-)

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/debian-science/packages/pytango.git



More information about the debian-science-commits mailing list