-
Notifications
You must be signed in to change notification settings - Fork 56
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
Drop py2.7 and add trio support! #55
Conversation
Relates to #20
The `defaults` kwarg to `pysipp.agent.Scenario` isn't used so just drop it and instead comb through provided `kwargs` and pop out values passed by the user into `pysipp.agent.Scenario.defaults` making these the "new" defaults applied to agents. Also, rename the default settings dicts more explicitly. Resolves #20
These fancy tuple-attribute-properties are supposed to be strictly assigned tuple types; let's enforce that. Resolves #12
After attempting to find an OS portable way to spawn subprocesses using the stdlib and coming out unsatisfied, I've decided use the new subprocess launching support in `trio`! This will of course require that the project moves to python 3.6+ giving us access to a lot of neat features of modern python including async/await support and adherence to the structured concurrency principles prominent in `trio`. It turns out this is a good fit since SIPp already has a built in cancellation mechanism via the SIGUSR1 signal. There's a lot of "core" changes to go over in this commit: - drop the "run protocol" and "runner creation" related hooks since they really shouldn't be overridden until there's some need for it and it's likely smarter to keep those "machinery" details strictly internal for now - the run "protocol" has now been relegated to an async function: `pysipp.launch.run_all_agents()` - many routines have been converted to async functions particularly at the runner (`pysipp.TrioRunner.run()`, `.get()`) and scenario (`pysipp.Scenario.arun()`) levels allowing us to expose both a sync and async interface for running subprocesses / agents - drop all the epoll/select loop stuff as this is entirely delegated to `trio.open_process()` and it's underlying machinery and APIs Resolves #53
Turns out we need to wait for the next version |
Back to only one test failing; the one for async launching which needs a rewrite and new docs for how to do with this |
hello, is there anything we can do to help merge this PR? |
@kontsaki my bad, I've let this slip quite a while 😿 I'm not currently working in telephony any more so haven't had any dire needs for this enhancement.
Testing and user feedback on the ergonomics would be good. We were supposed to do a proper release a while back. It would be good to get some further user feedback here on this though. |
Adheres to an interface similar to `multiprocessing.pool.AsyncResult`. | ||
class TrioRunner(object): | ||
"""Run a sequence of SIPp cmds asynchronously. If any process terminates | ||
with a non-zero exit code, immediately canacel all remaining processes and |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
typo, should be cancel
.
pysipp/launch.py
Outdated
# run agent commands in sequence | ||
for cmd in cmds: | ||
log.debug( | ||
"launching cmd:\n\"{}\"\n".format(cmd)) | ||
proc = sp.Popen( | ||
# proc = await trio.open_process( | ||
proc = trio.Process( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This api is now old.
We should probably port to the newer trio.open_process()
.
proc.streams = Streams(*proc.communicate()) # timeout=2)) | ||
if proc.returncode != 0 and not signalled: | ||
|
||
# taken mostly verbatim from ``trio.run_process()`` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There's also new work in python-trio/trio#1568 that will likely make some of this simpler.
@goodboy want me to open a PR for this branch if i get the chance and fix what you have commented? |
proc.stderr_output = await read_output(proc.stderr) | ||
|
||
try: | ||
with trio.fail_after(timeout): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@kontsaki yeah i'm thinking we should maybe factor this out just so it's clear that it's a global timeout?
Drop py27 more
@kontsaki I might just get this onto master as a new dev release so that interested peeps can try it out. Just need to tweak the release number.. |
Welp merged #67 and now the rebase on this branch will be a nightmare 😂 Not sure I'll get to it today. @kontsaki unfortunately that means #65 can't really be simplified yet either until this branch is fixed. This is why i normally don't do big formatting changes to someone else's code base when trying to get new features in 😉 We'll get through it eventually. |
i will fix the conflicts |
@kontsaki try doing a There's quite a few tweaks that are needed and afaik it can't be done wholesale using a |
merge master on drop_py27
Yah so this merge commit is not only imo messy it makes the history more confusing for onlookers. @kontsaki take a read of this https://stackoverflow.com/a/13194092 The main reason i would require this is not just for (as some people think is the only benefit),
If mainline is desynced by a few commits it's nbd, but it's when you're making changes to every file in the repo (i.e. in the case of #69) it's much easier to manage the history and see the origin of broad changes if those changes are isolated in a linear path of the git tree. |
Now there are paths both to |
i use a git alias: This (in imo) the cleanliness of rebasing and it comes at really no extra cost except forcing you to go over changes on your branch and potentially clean up your commits. Can be done nicely with |
Before we merge this I'd like to get some feedback from any users that are willing to alpha test it as well. I don't think there's much risk bringing it into If we get silence or feedback that everything is fine, we'll just merge and figure out peeps problems incrementally. |
I'm curious to know if anyone has actually used this branch for real testing; that would make it much easier to merge and move on. |
@goodboy are you willing to rebase this PR? |
@linuxmaniac yup just put up a redo with all merge conflicts fixed in #87 |
This is in preparation of a python 3.6+ only
1.0.0.alpha
release and replaces all the internal processing launching machinery with the new subprocess support intrio
.This not only gets us cross OS support for free but also gives access to
async
/await
based scenario and agent spawning.A few interesting notes:
SIPp
turns out to be a good fit withtrio
cancellation semantics since it has a built in cancellation system viaSIGUSR1
trio
gives us deterministic teardown allowing for much finer control over per agent failures and subsequent reportingTODO:
trio.move_on_after()
andtrio.fail_after()
and figure out how this can interplay with log reporting for interactive useI look forward to feedback and thoughts!
ping @y-luis