Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def blockOn(d, desc=None):
"""
Use me in non-main greenlets to wait for a Deferred to fire.
"""
g = greenlet.getcurrent()
if g is greenlet.main:
raise CalledFromMain("You cannot call blockOn from the main greenlet.")
if g.parent is greenlet.main:
mainOrNot = "(main)"
else:
mainOrNot = ""
#print _desc(g.parent), mainOrNot, "<-", hex(id(g)), "(%s)" % (desc,)
## Note ##
# Notice that this code catches and ignores SystemExit. The
# greenlet mechanism sends a SystemExit at a blocking greenlet if
# there is no chance that the greenlet will be fired by anyone
# else -- that is, no other greenlets have a reference to the one
# that's blocking.