
test_script.py
By: a guest on
Mar 13th, 2012 | syntax:
Python | size: 0.90 KB | hits: 31 | expires: Never
import kaboom
import stackless
from kaboom import *
# This implements the C++ interface that was wrapped for Python.
# The wrapper is called first, which gets the override for ReceiveExplosion.
# In there is code to ensure we have the GIL, and to release it afterwards.
# We're setting a stop variable kind of like I originally was doing in the more
# complicated code. I have found it doesn't actually matter, but should work
# when all is done.
class PoorGuy(ITimeBombCallback):
def __init__(self, stop_var):
ITimeBombCallback.__init__(self) # Very important for subclasses in Boost.Python
self.stop_var = stop_var
def ReceiveExplosion(self):
print "Got explosion"
self.stop_var = True
stop_var = False
poorGuy = PoorGuy(stop_var)
bomb = TimeBomb(poorGuy)
bomb.Go()
# Busy loop
while not stop_var:
stackless.schedule()
bomb.Join()