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

Run Subproc Refactor #1758

Merged
merged 147 commits into from Oct 5, 2016
Merged

Run Subproc Refactor #1758

merged 147 commits into from Oct 5, 2016

Conversation

scopatz
Copy link
Member

@scopatz scopatz commented Sep 24, 2016

This is a major overhaul of the way subprocs are executed.

The big idea here is that sub processes are now split into three pieces:

  • A process specification, which describes the process to be run and may be manipulated prior to execution
  • A process object, like Popen or ProcProxy, responsible for running a single command.
  • A command pipeline, which holds all specs and procs and in responsible for making sure that all procs in the pipeline read from and cleaned up correctly.

To enable the streaming and iterating features that we desired, a new PopenThread class has been introduced. This adheres to the Popen API and should be the last non-callable proc in the pipeline. This is responsible for running a regular Popen proc on a separate thread, and reading its output in a non-blocking manner (which was tricky!).

This PR also removes the TeePTY class and related psuedo-terminal handling. This PR should thus enable Storing stdout on all platforms now!

Please bang on this as there are things I have probably missed.

@AstraLuma
Copy link
Member

I think the timing issue is resolved well enough until we can fix it properly (I think we'll need some platform-specific work, unfortunately).

The bigger concern to me is the reports that some major programs (like vim) are just up and failing.

Breaking <.5% of calls is a problem, but something fixable. Breaking 100% of a major app? That's a blocker and must not make it to a release.

@scopatz
Copy link
Member Author

scopatz commented Oct 4, 2016

@astronouth7303 I have put in a fix for vim. Also, I think this is a good time to merge because it is right after a release. So we can bang on this in master before the next release. I agree that we shouldn't break anything major. But on some level it needs to have more exposure than a PR to find some of the harder to reach corner cases.

@ghost
Copy link

ghost commented Oct 4, 2016

vim is broken on this branch for me too.

$ old = tty.tcgetattr(sys.stdout)
$ vim
$ new = tty.tcgetattr(sys.stdout)
$ old == new
False

also i noticed that just running top on this branch, xonsh goes up to +35% cpu usage
and i think i don't see that happening on current master.
can someone confirm this please?

yes i think we should bring this in, even though it's a little unusable for me atm and i'll stay in .4.7 until this gets more stable, that's what the release was all about.

@scopatz
Copy link
Member Author

scopatz commented Oct 4, 2016

@laerus - can you try vim now? I was only fixing vi before... sorry!

@ghost
Copy link

ghost commented Oct 4, 2016

yep that's fixed, that list will grow.

backgrounding jobs is a little broken too.

@scopatz
Copy link
Member Author

scopatz commented Oct 4, 2016

yep that's fixed, that list will grow.

Absolutely.

backgrounding jobs is a little broken too.

It is a little broken on master too :)

@scopatz
Copy link
Member Author

scopatz commented Oct 5, 2016

Ok, I have added a new file and updated the docs a bit.

@@ -0,0 +1,42 @@
**Added:**

* New subprocess specification class ``SubprocSpec`` is sued for specifiying
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"sued"

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

dyslexicai not I am.


**Removed:**

* ``CompletedCommand`` and ``HiddenCompletedCommand`` classes have been removed.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So what does !() return now?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pipelines. I updated the news to mention this.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just !(ls) sometimes leaks output after printing the pipeline object.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It doesn't though, right, if you adjust your $XONSH_PROC_FREQUENCY... But I should add that to the news

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

@scopatz
Copy link
Member Author

scopatz commented Oct 5, 2016

Are there any other objections? I really do think that I have addressed everything that everyone has brought up that isn't platform specific, a performance or testing issue, or itself a refactor of this. If I am missing something, please let me know!

@gforsyth
Copy link
Collaborator

gforsyth commented Oct 5, 2016

I think this is ready to go -- in the interest of letting people get a word in if they need to, I'll hold off on merging this until noon EST

@gforsyth
Copy link
Collaborator

gforsyth commented Oct 5, 2016

Ok, here we go.

@gforsyth gforsyth merged commit 30e0b91 into master Oct 5, 2016
@gforsyth
Copy link
Collaborator

gforsyth commented Oct 5, 2016

Thanks, @scopatz !

🎉🎉🎉

@scopatz
Copy link
Member Author

scopatz commented Oct 5, 2016

Thanks @gforsyth! All!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

7 participants