def run(): import metacontext metacontext.register_importer_hook() import dis import traceback import example try: try: example.test(('test', 1)) except example.TestException: e = traceback.format_exc() print "GOT TRACEBACK", e assert 'line 37, in test' in e assert 'example.py' in e assert 'raise TestException("let\'s look at the stack trace")' in e example.other_test(('test', 1, 2)) try: example.MyActor().run() except example.TestException: e = traceback.format_exc() print "GOT SECOND TRACEBACK", e try: example.second_block(('test', 1)) except example.TestException: e = traceback.format_exc() print "GOT THIRD TRACEBACK", e finally: print "---------" print "X", repr(example.second_block.func_code.co_lnotab) dis.dis(example.second_block)
def onActivityStartup(self): releaseTest() example.test() self.log.info("Hello Python Activity startup")
import Cpyx Cpyx.cpyx('example', 'example_c', use_distutils=True) import example example.test(1, 2)
import sys sys.path.insert( 0, 'pyds%d%d' % (sys.version_info[0], sys.version_info[1]) ) import example example.test()
import sys sys.path.insert(0, 'pyds%d%d' % (sys.version_info[0], sys.version_info[1])) import example example.test()
import sys import zmq from types import ModuleType from numpush.zmq_net import numrecv ctx = zmq.Context.instance() sock = ctx.socket(zmq.PULL) sock.connect('tcp://127.0.0.1:5555') module = numrecv(sock) assert type(module) is ModuleType assert 'example' in sys.modules import example assert example.test(1,2) == 3