twitter-archive / commons

Twitter common libraries for python and the JVM (deprecated)
http://twitter.github.com/commons
Other
2.1k stars 565 forks source link

Make concurrent.deadline compatible with Python 3 #470

Closed StephanErb closed 5 years ago

StephanErb commented 5 years ago

Problem

twitter.common.concurrent cannot be imported with Python 3 due to the rename of Queue to queue. Additionally, the current exception handling code is incompatible with Python 3 scoping changes.

Solution

A few of imports in this repo have already been fixed to fail gracefully. Adopt the same workaround for all usages of Queue

Result

The following code runs with Python 3.6 as expected:

from twitter.common.concurrent import deadline

def myfunctor_happy():
    return "I am running deferred"

def myfunctor_unhappy():
    raise Exception("I am failing deferred")

print(deadline(myfunctor_happy, propagate=True))
print(deadline(myfunctor_unhappy, propagate=True))
CLAassistant commented 5 years ago

CLA assistant check
All committers have signed the CLA.