Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def run(self):
- """
- Start the event loop. Exit the loop when any callback raises
- an exception. If ExitMainLoop is raised, exit cleanly.
- >>> import os
- >>> rd, wr = os.pipe()
- >>> os.write(wr, "data") # something to read from rd
- 4
- >>> evl = TwistedEventLoop()
- >>> def say_hello_data():
- ... print "hello data"
- ... os.read(rd, 4)
- >>> def say_hello():
- ... print "hello"
- >>> handle = evl.watch_file(rd, say_hello_data)
- >>> def say_being_twisted():
- ... print "oh I'm messed up"
- ... raise ExitMainLoop
- >>> handle = evl.alarm(0.0625, say_being_twisted)
- >>> handle = evl.alarm(0.03125, say_hello)
- >>> evl.run()
- hello data
- hello
- oh I'm messed up
- """
- if not self.manage_reactor:
- self.reactor.run()
- if self._exc_info:
- # An exception caused us to exit, raise it now
- exc_info = self._exc_info
- self._exc_info = None
- raise exc_info[0], exc_info[1], exc_info[2]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement