What is a proper way to end an isolate

96 views
Skip to first unread message

Günter Zöchbauer

unread,
Sep 1, 2014, 4:59:47 AM9/1/14
to mi...@dartlang.org
What is a proper way to end an isolate created with spawn or spawnUri?
I'm primarily interested on the server but also curious whether it works the same way on the client. 

I asked this a while back on SO http://stackoverflow.com/questions/25531966 but didn't get an answer yet.

Filipe Morgado

unread,
Sep 1, 2014, 5:44:50 AM9/1/14
to mi...@dartlang.org
As far as I know, it's not possible yet (haven't checked for changes for a while though).

I think the proper way to do it would be to setup a communication mechanism between the parent and the children isolates.
The parent would send an "exit" message to the child that we want to close, the child closes all its pending listeners and sends a confirmation message back to the parent.

I haven't found a way to make sure the isolate actually exits, as there may be sockets, receive ports, files, etc ... we forgot to cleanup.
I guess it's sometimes a matter of "faith" :P

Günter Zöchbauer

unread,
Sep 1, 2014, 5:53:08 AM9/1/14
to mi...@dartlang.org
I guess there should be something like `exit()` from `dart:io` that doesn't end the entire application but only the current isolate.

Filipe Morgado

unread,
Sep 1, 2014, 6:09:35 AM9/1/14
to mi...@dartlang.org
Agreed.

Lasse R.H. Nielsen

unread,
Sep 1, 2014, 7:04:14 AM9/1/14
to mi...@dartlang.org
The current proper way is for the isolate itself to stop doing anything. That means having no scheduled microtasks or timers, and no open receive-ports. At that point, the isolate will shut itself down.

We are working on an Isolate API that allows the creator of an isolate to "kill" an isolate, but even with that, I'd still prefer to have the parent and child isolates communicate via some agreed protocol, so that the parent can tell the isolate to shut down cleanly, if at all possible.

/L


--
For other discussions, see https://groups.google.com/a/dartlang.org/
 
For HOWTO questions, visit http://stackoverflow.com/tags/dart
 
To file a bug report or feature request, go to http://www.dartbug.com/new

To unsubscribe from this group and stop receiving emails from it, send an email to misc+uns...@dartlang.org.



--
Lasse R.H. Nielsen - l...@google.com  
'Faith without judgement merely degrades the spirit divine'
Google Denmark ApS - Frederiksborggade 20B, 1 sal - 1360 København K - Denmark - CVR nr. 28 86 69 84

Günter Zöchbauer

unread,
Sep 1, 2014, 7:15:46 AM9/1/14
to mi...@dartlang.org
Thanks for the feedback.

It would be helpful to at least have some notification about an isolate shut down to verify if all things went well. 
I guess something like an event subscription can keep the isolate running (like main()) and they are easily missed.

Cogman

unread,
Sep 1, 2014, 11:22:28 AM9/1/14
to mi...@dartlang.org
At very least, it would be nice if a finished isolate could report its status.  For example, java has "#isAlive" on its threads.  It might be handy to have something similar on isolates.  That way the killer can send a friendly "Hey, die please" message and if nothing happens after x time period, he can brutally murder the isolate and notify everyone that he did it (making it easier to track down isolates that don't properly die).
Reply all
Reply to author
Forward
0 new messages