8000 SI-10007 sys.process thread sync by som-snytt · Pull Request #5481 · scala/scala · GitHub
[go: up one dir, main page]

Skip to content

SI-10007 sys.process thread sync #5481

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

Merged
merged 1 commit into from :issue/10007-process
Nov 18, 2016
Merged

Conversation

som-snytt
Copy link
Contributor

A previous change to replace SyncVar.set with SyncVar.put
breaks things.

This commit tweaks the thread synchronizing in sys.process
to actually use SyncVar to sync and pass a var.

Joining the thread about to exit is superfluous.

A result is put exactly once, and consumers use
non-destructive get.

Note that as usual, avoid kicking off threads in a static
context, since class loading cycles are somewhat dicier
with 2.12 lambdas. In particular, REPL is a static context
by default.

@scala-jenkins scala-jenkins added this to the 2.12.1 milestone Oct 26, 2016
@som-snytt
Copy link
Contributor Author

/rebuild

Copy link
Contributor
@ghik ghik left a comment

Choose a reason for hiding this comment

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

There are too many zeros in test file name :)

@som-snytt som-snytt force-pushed the issue/10007-process branch from 4284367 to 15593ff Compare November 3, 2016 16:59
@som-snytt
Copy link
Contributor Author

Rebased and changed test file name to scientific notation. :)

@som-snytt
Copy link
Contributor Author

/rebuild

1 similar comment
@SethTisue
Copy link
Member

/rebuild

class ProcessTest {
@Test def t10007(): Unit = {
val res = ("cat" #< new ByteArrayInputStream("lol".getBytes)).!!
assertEquals("lol\n", res)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Test won't fly on windows, sorry, @SethTisue

@lrytz
Copy link
Member
lrytz commented Nov 16, 2016

LGTM - except for that test on windows.. should we just guard it with System.getProperty("os.name").toLowerCase.contains("windows")?

8000

@som-snytt
Copy link
Contributor Author

I added the SI-10055 test because nothing good happens after midnight. It doesn't really add anything but time. Or I guess it tests the lambda initialization. The call-by-name arg could be invoked anywhere, including a static init where it could block. Sorry, Jenkins, I was too sleepy to compile and test before bed, would you do that, there's a good chap.

@@ -91,12 +91,11 @@ private[process] trait ProcessImpl {

protected lazy val (processThread, getExitValue, destroyer) = {
val code = new SyncVar[Option[Int]]()
code.put(None)
val thread = Spawn(code.put(runAndExitValue()))
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Should this be try-finally like at ProcessBuilderImpl L61?

@lrytz
Copy link
Member
lrytz commented Nov 16, 2016

LGTM, thanks for these cleanups!

@lrytz
Copy link
Member
lrytz commented Nov 17, 2016

Not sure if t9752.scala is a spurious failure.

I just saw this now: could you rename t10007.scala to ProcessTest.scala?

A previous change to replace `SyncVar.set` with `SyncVar.put`
breaks things.

This commit tweaks the thread synchronizing in `sys.process`
to actually use `SyncVar` to sync and pass a var.

Joining the thread about to exit is superfluous.

A result is put exactly once, and consumers use
non-destructive `get`.

Note that as usual, avoid kicking off threads in a static
context, since class loading cycles are somewhat dicier
with 2.12 lambdas. In particular, REPL is a static context
by default.

SI-10007 Clarify deprecation message

The message on `set` was self-fulfilling, as it didn't
hint that `put` has different semantics.

So explain why `put` helps avoid errors instead of
creating them.

SI-10007 Always set exit value

Always put a value to exit code, defaulting to None.

Also clean up around tuple change to unfortunately
named Future.apply. Very hard to follow those types.

Date command pollutes output, so tweak test.
@som-snytt
Copy link
Contributor Author

Hopefully spurious. I renamed both those junit files and squashed.

@som-snytt
Copy link
Contributor Author

Test rig is failing badly. I won't rebuild at this time.

@adriaanm
Copy link
Contributor

/rebuild

The OOMpas are at it again. Rig is feeling fresher now, it looks like.

@lrytz
Copy link
Member
lrytz commented Nov 18, 2016

Thanks, @som-snytt

@lrytz lrytz merged commit 40f8df1 into scala:2.12.x Nov 18, 2016
@som-snytt som-snytt deleted the issue/10007-process branch November 18, 2016 08:30
szeiger added a commit to szeiger/scala that referenced this pull request Nov 21, 2016
The changes were made in scala#5481,
subsequently breaking binary compatibility checks after
scala#5532 was merged, too. The affected
methods are part of an internal implementation class. Whitelisting
should be safe.
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.

6 participants
0