Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Help] How to test twisted code #109

Open
whg517 opened this issue Jan 8, 2021 · 0 comments
Open

[Help] How to test twisted code #109

whg517 opened this issue Jan 8, 2021 · 0 comments
Labels

Comments

@whg517
Copy link

whg517 commented Jan 8, 2021

Description

I have sample example, when i run, but an error occurred.

from twisted.internet import reactor, task
from vprof import runner


def ppp():
    print('called')


def profile():
    reactor.callLater(3, reactor.stop)
    t = task.LoopingCall(ppp)
    t.start(0.5)
    reactor.run()


if __name__ == '__main__':
    runner.run(profile, 'cmhp')
Traceback (most recent call last):
  File "/home/kevin/workspaces/develop/python/crawlerstack/crawlerstack_proxypool/demo.py", line 19, in <module>
    runner.run(profile, 'cmhp')
  File "/home/kevin/.virtualenvs/crawlerstack_proxypool-VZQM9sgQ/lib/python3.7/site-packages/vprof/runner.py", line 91, in run
    run_stats = run_profilers((func, args, kwargs), options)
  File "/home/kevin/.virtualenvs/crawlerstack_proxypool-VZQM9sgQ/lib/python3.7/site-packages/vprof/runner.py", line 73, in run_profilers
    run_stats[option] = curr_profiler.run()
  File "/home/kevin/.virtualenvs/crawlerstack_proxypool-VZQM9sgQ/lib/python3.7/site-packages/vprof/base_profiler.py", line 172, in run
    return self.profile()
  File "/home/kevin/.virtualenvs/crawlerstack_proxypool-VZQM9sgQ/lib/python3.7/site-packages/vprof/flame_graph.py", line 172, in profile_function
    result = self._run_object(*self._run_args, **self._run_kwargs)
  File "/home/kevin/workspaces/develop/python/crawlerstack/crawlerstack_proxypool/demo.py", line 15, in profile
    reactor.run()
  File "/home/kevin/.virtualenvs/crawlerstack_proxypool-VZQM9sgQ/lib/python3.7/site-packages/twisted/internet/base.py", line 1282, in run
    self.startRunning(installSignalHandlers=installSignalHandlers)
  File "/home/kevin/.virtualenvs/crawlerstack_proxypool-VZQM9sgQ/lib/python3.7/site-packages/twisted/internet/base.py", line 1262, in startRunning
    ReactorBase.startRunning(self)
  File "/home/kevin/.virtualenvs/crawlerstack_proxypool-VZQM9sgQ/lib/python3.7/site-packages/twisted/internet/base.py", line 765, in startRunning
    raise error.ReactorNotRestartable()
twisted.internet.error.ReactorNotRestartable
Version and platform
  • vprof 0.38
  • Linux 5.4.70-amd64-desktop #1 SMP Wed Oct 14 15:24:23 CST 2020 x86_64 GNU/Linux
  • Python 3.7.3
  • twisted 20.3.0
@whg517 whg517 changed the title How to test twisted code [Help] How to test twisted code Jan 8, 2021
@nvdv nvdv added the question label Jan 31, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants