You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@pekko.apache.org by "mdedetrich (via GitHub)" <gi...@apache.org> on 2025/11/12 15:31:16 UTC
[PR] Add close on ActorSystem [pekko]
mdedetrich opened a new pull request, #2486:
URL: https://github.com/apache/pekko/pull/2486
Adds the `close` method on `ActorSystem` (classic and typed) as well as implementing the `AutoCloseable` interface, work taken from https://github.com/apache/pekko/pull/2479.
Regardless of what happens with https://github.com/apache/pekko/issues/2093, the changes in this PR are always valid (`close` is blocking and returns `Unit`/`Void` so its valid for both `javadsl` and `scaladsl`)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@pekko.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@pekko.apache.org
For additional commands, e-mail: notifications-help@pekko.apache.org
Re: [PR] Add close on ActorSystem [pekko]
Posted by "He-Pin (via GitHub)" <gi...@apache.org>.
He-Pin commented on code in PR #2486:
URL: https://github.com/apache/pekko/pull/2486#discussion_r2521369096
##########
actor/src/main/scala/org/apache/pekko/actor/ActorSystem.scala:
##########
@@ -1080,6 +1100,14 @@ private[pekko] class ActorSystemImpl(
whenTerminated
}
+ override def close(): Unit = {
Review Comment:
@throws(classOf[TimeoutException])
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@pekko.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@pekko.apache.org
For additional commands, e-mail: notifications-help@pekko.apache.org
Re: [PR] Add close on ActorSystem [pekko]
Posted by "mdedetrich (via GitHub)" <gi...@apache.org>.
mdedetrich commented on code in PR #2486:
URL: https://github.com/apache/pekko/pull/2486#discussion_r2522337259
##########
actor-testkit-typed/src/main/scala/org/apache/pekko/actor/testkit/typed/internal/ActorSystemStub.scala:
##########
@@ -113,6 +113,10 @@ import com.typesafe.config.{ Config, ConfigFactory }
override def terminate(): Unit = terminationPromise.trySuccess(Done)
override def whenTerminated: Future[Done] = terminationPromise.future
override def getWhenTerminated: CompletionStage[Done] = whenTerminated.asJava
+ override def close(): Unit = {
+ terminate()
+ Await.result(whenTerminated, scala.concurrent.duration.Duration.Inf)
Review Comment:
Actually in quite a few places we have `Await.result(whenTerminated, scala.concurrent.duration.Duration.Inf)`, not just here where I introduced it. I can do it, but this method isn't even executed/called so its quite benign and from what I can tell the purpose of this `ActorSystemStub` is to not use any config in order to make it easier to programmatically setup test scenarios.
I did look for any kind of timeout that can be used, but there isn't any in this context.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@pekko.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@pekko.apache.org
For additional commands, e-mail: notifications-help@pekko.apache.org
Re: [PR] Add close on ActorSystem [pekko]
Posted by "samueleresca (via GitHub)" <gi...@apache.org>.
samueleresca commented on PR #2486:
URL: https://github.com/apache/pekko/pull/2486#issuecomment-3524077167
Does this PR also need to update [ActorSystemLifecycle.scala#L54](https://github.com/apache/pekko/blob/main/stream-tests-tck/src/test/scala/org/apache/pekko/stream/tck/ActorSystemLifecycle.scala#L54)?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@pekko.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@pekko.apache.org
For additional commands, e-mail: notifications-help@pekko.apache.org
Re: [PR] Add close on ActorSystem [pekko]
Posted by "pjfanning (via GitHub)" <gi...@apache.org>.
pjfanning commented on PR #2486:
URL: https://github.com/apache/pekko/pull/2486#issuecomment-3523033602
> > Would it be acceptable to not put this on ActorSystem but create a factory method like `ActorSystem.createWithBlockingClose()` or `ActorSystem.apply(withBlockingClose: Boolean = false)`?
>
> Well I would still have to put it on `ActorSystem` otherwise `AutoCloseable` won't work, but I can make the blocking behaviour configurable (alternately it can go in `reference.conf` though given that `close` should block by default)>
>
> I think the point is, if you are going to use `close()` and don't want it to block, at that point you are already rolling your own resource cleaning mechanism at which point `close()` + `AutoCloseable` is kind of pointless. There are also already methods that do close in an async manner (thats what `.terminate()` does).
A config option to decide on whether the close is blocking alongside a config to control the timeout for blocking seems ok.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@pekko.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@pekko.apache.org
For additional commands, e-mail: notifications-help@pekko.apache.org
Re: [PR] Add close on ActorSystem [pekko]
Posted by "mdedetrich (via GitHub)" <gi...@apache.org>.
mdedetrich commented on code in PR #2486:
URL: https://github.com/apache/pekko/pull/2486#discussion_r2522160353
##########
actor/src/main/resources/reference.conf:
##########
@@ -1244,6 +1244,9 @@ pekko {
# Terminate the ActorSystem in the last phase actor-system-terminate.
terminate-actor-system = on
+ # The timeout that will be used when calling .close on an ActorSystem
+ close-actor-system-timeout = 60 s
Review Comment:
1Day is way too much, people calling terminate will expect it to do so in a reasonable time especially if they are doing it before a pod/server/instance is shutting down.
1 minute is a good default in my view
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@pekko.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@pekko.apache.org
For additional commands, e-mail: notifications-help@pekko.apache.org
Re: [PR] Add close on ActorSystem [pekko]
Posted by "He-Pin (via GitHub)" <gi...@apache.org>.
He-Pin commented on PR #2486:
URL: https://github.com/apache/pekko/pull/2486#issuecomment-3536706025
I will do the backporting
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@pekko.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@pekko.apache.org
For additional commands, e-mail: notifications-help@pekko.apache.org
Re: [PR] Add close on ActorSystem [pekko]
Posted by "He-Pin (via GitHub)" <gi...@apache.org>.
He-Pin commented on PR #2486:
URL: https://github.com/apache/pekko/pull/2486#issuecomment-3536706535
@mdedetrich Nice you are online, hands over~
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@pekko.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@pekko.apache.org
For additional commands, e-mail: notifications-help@pekko.apache.org
Re: [PR] Add close on ActorSystem [pekko]
Posted by "mdedetrich (via GitHub)" <gi...@apache.org>.
mdedetrich commented on code in PR #2486:
URL: https://github.com/apache/pekko/pull/2486#discussion_r2522042813
##########
actor/src/main/resources/reference.conf:
##########
@@ -1244,6 +1244,9 @@ pekko {
# Terminate the ActorSystem in the last phase actor-system-terminate.
terminate-actor-system = on
+ # The timeout that will be used when calling .close on an ActorSystem
Review Comment:
Same as https://github.com/apache/pekko/pull/2486#discussion_r2521369096, this is not part of public API
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@pekko.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@pekko.apache.org
For additional commands, e-mail: notifications-help@pekko.apache.org
Re: [PR] Add close on ActorSystem [pekko]
Posted by "mdedetrich (via GitHub)" <gi...@apache.org>.
mdedetrich commented on PR #2486:
URL: https://github.com/apache/pekko/pull/2486#issuecomment-3523023835
> Would it be acceptable to not put this on ActorSystem but create a factory method like `ActorSystem.createWithBlockingClose()` or `ActorSystem.apply(withBlockingClose: Boolean = false)`?
Well I would still have to put it on `ActorSystem` otherwise `AutoCloseable` won't work, but I can make the blocking behaviour configurable (alternately it can go in `reference.conf` though given that `close` should block by default)>
I think the point is, if you are going to use `close()` and don't want it to block, at that point you are already rolling your own resource cleaning mechanism at which point `close()` + `AutoCloseable` is kind of pointless. There are also already methods that do close in an async manner (thats what `.terminate()` does).
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@pekko.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@pekko.apache.org
For additional commands, e-mail: notifications-help@pekko.apache.org
Re: [PR] Add close on ActorSystem [pekko]
Posted by "pjfanning (via GitHub)" <gi...@apache.org>.
pjfanning commented on PR #2486:
URL: https://github.com/apache/pekko/pull/2486#issuecomment-3523007086
Would it be acceptable to not put this on ActorSystem but create a factory method like `ActorSystem.createWithBlockingClose()` or `ActorSystem.apply(withBlockingClose: Boolean = false)`?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@pekko.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@pekko.apache.org
For additional commands, e-mail: notifications-help@pekko.apache.org
Re: [PR] Add close on ActorSystem [pekko]
Posted by "mdedetrich (via GitHub)" <gi...@apache.org>.
mdedetrich commented on PR #2486:
URL: https://github.com/apache/pekko/pull/2486#issuecomment-3526113380
I will wait a few days to see if @raboof responds and also his views on making the blocking nature configurable
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@pekko.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@pekko.apache.org
For additional commands, e-mail: notifications-help@pekko.apache.org
Re: [PR] Add close on ActorSystem [pekko]
Posted by "He-Pin (via GitHub)" <gi...@apache.org>.
He-Pin merged PR #2486:
URL: https://github.com/apache/pekko/pull/2486
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@pekko.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@pekko.apache.org
For additional commands, e-mail: notifications-help@pekko.apache.org
Re: [PR] Add close on ActorSystem [pekko]
Posted by "mdedetrich (via GitHub)" <gi...@apache.org>.
mdedetrich commented on PR #2486:
URL: https://github.com/apache/pekko/pull/2486#issuecomment-3526104105
> btw, @mdedetrich what's the status of kotlin dsl of Pekko?
I have some good news on this front, there is an official sbt kotlin plugin by jetbrains so it should be largely trivial https://github.com/JetBrains/sbt-kotlin-plugin
The thing is that its blocked by https://github.com/apache/pekko/issues/2093 as kotlion also has its own way of handling async IO (it has suspend functions)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@pekko.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@pekko.apache.org
For additional commands, e-mail: notifications-help@pekko.apache.org
Re: [PR] Add close on ActorSystem [pekko]
Posted by "raboof (via GitHub)" <gi...@apache.org>.
raboof commented on PR #2486:
URL: https://github.com/apache/pekko/pull/2486#issuecomment-3522645546
> `close` is blocking and returns `Unit`/`Void`
Is there a requirement for close to block until the closing is 'complete'?
> The PR also cleans up test code by removing the `Await.result(system.close,...)` pattern that is used everywhere.
I can see the appeal, though blocking is a bit 'uncharacteristic' for us. I guess because you're stopping the ActorSystem and thus are anyway 'on your way out' it might be fine?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@pekko.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@pekko.apache.org
For additional commands, e-mail: notifications-help@pekko.apache.org
Re: [PR] Add close on ActorSystem [pekko]
Posted by "He-Pin (via GitHub)" <gi...@apache.org>.
He-Pin commented on code in PR #2486:
URL: https://github.com/apache/pekko/pull/2486#discussion_r2521380023
##########
actor-typed/src/main/scala/org/apache/pekko/actor/typed/internal/adapter/ActorSystemAdapter.scala:
##########
@@ -122,6 +122,8 @@ import org.slf4j.{ Logger, LoggerFactory }
override lazy val getWhenTerminated: CompletionStage[pekko.Done] =
whenTerminated.asJava
+ override def close(): Unit = system.close()
Review Comment:
@throws(classOf[TimeoutException])
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@pekko.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@pekko.apache.org
For additional commands, e-mail: notifications-help@pekko.apache.org
Re: [PR] Add close on ActorSystem [pekko]
Posted by "raboof (via GitHub)" <gi...@apache.org>.
raboof commented on PR #2486:
URL: https://github.com/apache/pekko/pull/2486#issuecomment-3522830185
> > Is there a requirement for close to block until the closing is 'complete'?
>
> I believe so otherwise you can get weird behaviour but I will do research to confirm. From what I gather (and also when learning Kotlin and using stuff like Arrow Resource), `AutoCloseable` is kind of pointless if the `close` method is asynchronous
Why? When I want to make sure the cleanup is triggered but don't care too much when it happens, it might be fine?
> which is why you have stuff like https://docs.datastax.com/en/latest-java-driver-api/com/datastax/oss/driver/api/core/AsyncAutoCloseable.html
It's an interesting data point that the `close` of that one is also blocking.
> > I can see the appeal, though blocking is a bit 'uncharacteristic' for us. I guess because you're stopping the ActorSystem and thus are anyway 'on your way out' it might be fine?
>
> To clarify, if I replace `Await.result` with `close` its because the behaviour of blocking is exactly the same. In those cases, the only thing that would have changed would be the timeout (i.e. sometimes it was 15 seconds, sometimes 20 but these are all tests so it shouldn't be an issue anyways).
Sure, I meant blocking in the 'production' code is a bit uncharacteristic - in tests it's indeed definitely fine.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@pekko.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@pekko.apache.org
For additional commands, e-mail: notifications-help@pekko.apache.org
Re: [PR] Add close on ActorSystem [pekko]
Posted by "mdedetrich (via GitHub)" <gi...@apache.org>.
mdedetrich commented on PR #2486:
URL: https://github.com/apache/pekko/pull/2486#issuecomment-3536706218
> I will do the backporting
Please let me do it as I have to modify a test
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@pekko.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@pekko.apache.org
For additional commands, e-mail: notifications-help@pekko.apache.org
Re: [PR] Add close on ActorSystem [pekko]
Posted by "He-Pin (via GitHub)" <gi...@apache.org>.
He-Pin commented on PR #2486:
URL: https://github.com/apache/pekko/pull/2486#issuecomment-3536684719
This seems the last pr target 1.3.0
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@pekko.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@pekko.apache.org
For additional commands, e-mail: notifications-help@pekko.apache.org
Re: [PR] Add close on ActorSystem [pekko]
Posted by "mdedetrich (via GitHub)" <gi...@apache.org>.
mdedetrich commented on PR #2486:
URL: https://github.com/apache/pekko/pull/2486#issuecomment-3526480836
I have just updated the PR to actually add tests to make sure the `AutoCloseable` works as expected. There is a Java test that uses try-with-resources and there is a Scala test using `scala.util.Using` (which automatically uses `AutoCloseable`).
One note is that when I cherry pick this into Pekko 1.3.x, the `scala.util.Using` tests will only work for Scala 2.13/Scala 3 so I will need to modify the tests there.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@pekko.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@pekko.apache.org
For additional commands, e-mail: notifications-help@pekko.apache.org
Re: [PR] Add close on ActorSystem [pekko]
Posted by "mdedetrich (via GitHub)" <gi...@apache.org>.
mdedetrich commented on code in PR #2486:
URL: https://github.com/apache/pekko/pull/2486#discussion_r2522737985
##########
actor/src/main/resources/reference.conf:
##########
@@ -1244,6 +1244,9 @@ pekko {
# Terminate the ActorSystem in the last phase actor-system-terminate.
terminate-actor-system = on
+ # The timeout that will be used when calling .close on an ActorSystem
Review Comment:
Do we have an example of what this is meant to look like?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@pekko.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@pekko.apache.org
For additional commands, e-mail: notifications-help@pekko.apache.org
Re: [PR] Add close on ActorSystem [pekko]
Posted by "mdedetrich (via GitHub)" <gi...@apache.org>.
mdedetrich commented on PR #2486:
URL: https://github.com/apache/pekko/pull/2486#issuecomment-3522918930
So regarding blocking on `close()`, the official documentation from https://docs.oracle.com/javase/tutorial/essential/exceptions/tryResourceClose.html i.e.
> See the Javadoc of the [AutoCloseable](https://docs.oracle.com/javase/8/docs/api/java/lang/AutoCloseable.html) and [Closeable](https://docs.oracle.com/javase/8/docs/api/java/io/Closeable.html) interfaces for a list of classes that implement either of these interfaces. The Closeable interface extends the AutoCloseable interface. The close method of the Closeable interface throws exceptions of type IOException while the close method of the AutoCloseable interface throws exceptions of type Exception. Consequently, subclasses of the AutoCloseable interface can override this behavior of the close method to throw specialized exceptions, such as IOException, or no exception at all.
And more directly from https://docs.oracle.com/javase/8/docs/api/java/lang/AutoCloseable.html
> While this interface method is declared to throw Exception, implementers are strongly encouraged to declare concrete implementations of the close method to throw more specific exceptions, or to throw no exception at all if the close operation cannot fail.
> Cases where the close operation may fail require careful attention by implementers. It is strongly advised to relinquish the underlying resources and to internally mark the resource as closed, prior to throwing the exception. The close method is unlikely to be invoked more than once and so this ensures that the resources are released in a timely manner. Furthermore it reduces problems that could arise when the resource wraps, or is wrapped, by another resource.
Implies that it is expected that if the `close()` method fails that an exception should be thrown. It is possible for `ActorSystem.terminate()` to fail and the only way to throw an exception in this case is to block on it.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@pekko.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@pekko.apache.org
For additional commands, e-mail: notifications-help@pekko.apache.org
Re: [PR] Add close on ActorSystem [pekko]
Posted by "He-Pin (via GitHub)" <gi...@apache.org>.
He-Pin commented on code in PR #2486:
URL: https://github.com/apache/pekko/pull/2486#discussion_r2521367899
##########
actor/src/main/scala/org/apache/pekko/actor/ActorSystem.scala:
##########
@@ -1080,6 +1100,14 @@ private[pekko] class ActorSystemImpl(
whenTerminated
}
+ override def close(): Unit = {
+ terminate()
+ val duration =
+ Duration(settings.config.getDuration("pekko.coordinated-shutdown.close-actor-system-timeout").toMillis,
+ TimeUnit.MILLISECONDS)
Review Comment:
nice with a default duration!
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@pekko.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@pekko.apache.org
For additional commands, e-mail: notifications-help@pekko.apache.org
Re: [PR] Add close on ActorSystem [pekko]
Posted by "He-Pin (via GitHub)" <gi...@apache.org>.
He-Pin commented on code in PR #2486:
URL: https://github.com/apache/pekko/pull/2486#discussion_r2521549273
##########
actor-typed/src/main/scala/org/apache/pekko/actor/typed/internal/adapter/ActorSystemAdapter.scala:
##########
@@ -122,6 +122,8 @@ import org.slf4j.{ Logger, LoggerFactory }
override lazy val getWhenTerminated: CompletionStage[pekko.Done] =
whenTerminated.asJava
+ override def close(): Unit = system.close()
Review Comment:
add `@since 1.3.0`
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@pekko.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@pekko.apache.org
For additional commands, e-mail: notifications-help@pekko.apache.org
Re: [PR] Add close on ActorSystem [pekko]
Posted by "mdedetrich (via GitHub)" <gi...@apache.org>.
mdedetrich commented on PR #2486:
URL: https://github.com/apache/pekko/pull/2486#issuecomment-3522880849
> Why? When I want to make sure the cleanup is triggered but don't care too much when it happens, it might be fine?
From what I recall, if there is an error in cleaning up on `close()` its expected that an exception be thrown which is not possible if its asynchronous but I will look into it.
I would say personally that having `close()` cleaning up resources in an asynchronous manner would be surprising behaviour
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@pekko.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@pekko.apache.org
For additional commands, e-mail: notifications-help@pekko.apache.org
Re: [PR] Add close on ActorSystem [pekko]
Posted by "mdedetrich (via GitHub)" <gi...@apache.org>.
mdedetrich commented on PR #2486:
URL: https://github.com/apache/pekko/pull/2486#issuecomment-3522728290
> Is there a requirement for close to block until the closing is 'complete'?
I believe so otherwise you can get weird behaviour but I will do research to confirm
> I can see the appeal, though blocking is a bit 'uncharacteristic' for us. I guess because you're stopping the ActorSystem and thus are anyway 'on your way out' it might be fine?
To clarify, if I replace `Await.result` with `close` its because the behaviour of blocking is exactly the same. In those cases, the only thing that would have changed would be the timeout (i.e. sometimes it was 15 seconds, sometimes 20 but these are all tests so it shouldn't be an issue anyways).
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@pekko.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@pekko.apache.org
For additional commands, e-mail: notifications-help@pekko.apache.org
Re: [PR] Add close on ActorSystem [pekko]
Posted by "He-Pin (via GitHub)" <gi...@apache.org>.
He-Pin commented on code in PR #2486:
URL: https://github.com/apache/pekko/pull/2486#discussion_r2521375156
##########
actor/src/main/scala/org/apache/pekko/actor/ActorSystem.scala:
##########
@@ -1080,6 +1100,14 @@ private[pekko] class ActorSystemImpl(
whenTerminated
}
+ override def close(): Unit = {
+ terminate()
+ val duration =
+ Duration(settings.config.getDuration("pekko.coordinated-shutdown.close-actor-system-timeout").toMillis,
+ TimeUnit.MILLISECONDS)
Review Comment:
missed the `@throws(classOf[TimeoutException])`
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@pekko.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@pekko.apache.org
For additional commands, e-mail: notifications-help@pekko.apache.org
Re: [PR] Add close on ActorSystem [pekko]
Posted by "He-Pin (via GitHub)" <gi...@apache.org>.
He-Pin commented on code in PR #2486:
URL: https://github.com/apache/pekko/pull/2486#discussion_r2521369096
##########
actor/src/main/scala/org/apache/pekko/actor/ActorSystem.scala:
##########
@@ -1080,6 +1100,14 @@ private[pekko] class ActorSystemImpl(
whenTerminated
}
+ override def close(): Unit = {
Review Comment:
Add some document, for it will just wait `xxx` long.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@pekko.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@pekko.apache.org
For additional commands, e-mail: notifications-help@pekko.apache.org
Re: [PR] Add close on ActorSystem [pekko]
Posted by "He-Pin (via GitHub)" <gi...@apache.org>.
He-Pin commented on PR #2486:
URL: https://github.com/apache/pekko/pull/2486#issuecomment-3525356426
Once get merged, this should be ported to 2.0.0
btw, @mdedetrich what's the status of kotlin dsl of Pekko?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@pekko.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@pekko.apache.org
For additional commands, e-mail: notifications-help@pekko.apache.org
Re: [PR] Add close on ActorSystem [pekko]
Posted by "mdedetrich (via GitHub)" <gi...@apache.org>.
mdedetrich commented on code in PR #2486:
URL: https://github.com/apache/pekko/pull/2486#discussion_r2522036155
##########
actor/src/main/scala/org/apache/pekko/actor/ActorSystem.scala:
##########
@@ -1080,6 +1100,14 @@ private[pekko] class ActorSystemImpl(
whenTerminated
}
+ override def close(): Unit = {
Review Comment:
This is the implementation, the parent which defines the abstract method (`ActorSystem`) has `@throws(classOf[TimeoutException])` which is what matters for users, I think thats enough?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@pekko.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@pekko.apache.org
For additional commands, e-mail: notifications-help@pekko.apache.org
Re: [PR] Add close on ActorSystem [pekko]
Posted by "mdedetrich (via GitHub)" <gi...@apache.org>.
mdedetrich commented on PR #2486:
URL: https://github.com/apache/pekko/pull/2486#issuecomment-3523035760
> A config option to decide on whether the close is blocking alongside a config to control the timeout for blocking seems ok.
Cool, Ill see feedback from others as well
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@pekko.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@pekko.apache.org
For additional commands, e-mail: notifications-help@pekko.apache.org
Re: [PR] Add close on ActorSystem [pekko]
Posted by "pjfanning (via GitHub)" <gi...@apache.org>.
pjfanning commented on code in PR #2486:
URL: https://github.com/apache/pekko/pull/2486#discussion_r2522268843
##########
actor-testkit-typed/src/main/scala/org/apache/pekko/actor/testkit/typed/internal/ActorSystemStub.scala:
##########
@@ -113,6 +113,10 @@ import com.typesafe.config.{ Config, ConfigFactory }
override def terminate(): Unit = terminationPromise.trySuccess(Done)
override def whenTerminated: Future[Done] = terminationPromise.future
override def getWhenTerminated: CompletionStage[Done] = whenTerminated.asJava
+ override def close(): Unit = {
+ terminate()
+ Await.result(whenTerminated, scala.concurrent.duration.Duration.Inf)
Review Comment:
Not a big deal but could this use the timeout config discussed elsewhere?
I've never been a big fan of tests that potentially wait indefinitely, eg in CI runs.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@pekko.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@pekko.apache.org
For additional commands, e-mail: notifications-help@pekko.apache.org
Re: [PR] Add close on ActorSystem [pekko]
Posted by "He-Pin (via GitHub)" <gi...@apache.org>.
He-Pin commented on code in PR #2486:
URL: https://github.com/apache/pekko/pull/2486#discussion_r2521367899
##########
actor/src/main/scala/org/apache/pekko/actor/ActorSystem.scala:
##########
@@ -1080,6 +1100,14 @@ private[pekko] class ActorSystemImpl(
whenTerminated
}
+ override def close(): Unit = {
+ terminate()
+ val duration =
+ Duration(settings.config.getDuration("pekko.coordinated-shutdown.close-actor-system-timeout").toMillis,
+ TimeUnit.MILLISECONDS)
Review Comment:
@throws(classOf[TimeoutException])
##########
actor/src/main/scala/org/apache/pekko/actor/ActorSystem.scala:
##########
@@ -1080,6 +1100,14 @@ private[pekko] class ActorSystemImpl(
whenTerminated
}
+ override def close(): Unit = {
+ terminate()
+ val duration =
+ Duration(settings.config.getDuration("pekko.coordinated-shutdown.close-actor-system-timeout").toMillis,
+ TimeUnit.MILLISECONDS)
Review Comment:
missed the `@throws(classOf[TimeoutException])`
##########
actor/src/main/scala/org/apache/pekko/actor/ActorSystem.scala:
##########
@@ -1080,6 +1100,14 @@ private[pekko] class ActorSystemImpl(
whenTerminated
}
+ override def close(): Unit = {
+ terminate()
+ val duration =
+ Duration(settings.config.getDuration("pekko.coordinated-shutdown.close-actor-system-timeout").toMillis,
+ TimeUnit.MILLISECONDS)
Review Comment:
@throws(classOf[TimeoutException])
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@pekko.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@pekko.apache.org
For additional commands, e-mail: notifications-help@pekko.apache.org
Re: [PR] Add close on ActorSystem [pekko]
Posted by "He-Pin (via GitHub)" <gi...@apache.org>.
He-Pin commented on code in PR #2486:
URL: https://github.com/apache/pekko/pull/2486#discussion_r2521378110
##########
actor/src/main/resources/reference.conf:
##########
@@ -1244,6 +1244,9 @@ pekko {
# Terminate the ActorSystem in the last phase actor-system-terminate.
terminate-actor-system = on
+ # The timeout that will be used when calling .close on an ActorSystem
+ close-actor-system-timeout = 60 s
Review Comment:
ForkJoinPool's default is `1Day`
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@pekko.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@pekko.apache.org
For additional commands, e-mail: notifications-help@pekko.apache.org
Re: [PR] Add close on ActorSystem [pekko]
Posted by "He-Pin (via GitHub)" <gi...@apache.org>.
He-Pin commented on code in PR #2486:
URL: https://github.com/apache/pekko/pull/2486#discussion_r2521551517
##########
actor/src/main/resources/reference.conf:
##########
@@ -1244,6 +1244,9 @@ pekko {
# Terminate the ActorSystem in the last phase actor-system-terminate.
terminate-actor-system = on
+ # The timeout that will be used when calling .close on an ActorSystem
Review Comment:
add `since 1.3.0`
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@pekko.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@pekko.apache.org
For additional commands, e-mail: notifications-help@pekko.apache.org
Re: [PR] Add close on ActorSystem [pekko]
Posted by "mdedetrich (via GitHub)" <gi...@apache.org>.
mdedetrich commented on code in PR #2486:
URL: https://github.com/apache/pekko/pull/2486#discussion_r2522039310
##########
actor-typed/src/main/scala/org/apache/pekko/actor/typed/internal/adapter/ActorSystemAdapter.scala:
##########
@@ -122,6 +122,8 @@ import org.slf4j.{ Logger, LoggerFactory }
override lazy val getWhenTerminated: CompletionStage[pekko.Done] =
whenTerminated.asJava
+ override def close(): Unit = system.close()
Review Comment:
Same as https://github.com/apache/pekko/pull/2486#discussion_r2521369096, this is the implementation and end users won't see it (they will see the abstract method)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@pekko.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@pekko.apache.org
For additional commands, e-mail: notifications-help@pekko.apache.org
Re: [PR] Add close on ActorSystem [pekko]
Posted by "mdedetrich (via GitHub)" <gi...@apache.org>.
mdedetrich commented on code in PR #2486:
URL: https://github.com/apache/pekko/pull/2486#discussion_r2522042426
##########
actor-typed/src/main/scala/org/apache/pekko/actor/typed/internal/adapter/ActorSystemAdapter.scala:
##########
@@ -122,6 +122,8 @@ import org.slf4j.{ Logger, LoggerFactory }
override lazy val getWhenTerminated: CompletionStage[pekko.Done] =
whenTerminated.asJava
+ override def close(): Unit = system.close()
Review Comment:
Same as https://github.com/apache/pekko/pull/2486#discussion_r2521369096, this is not part of public API
##########
actor/src/main/resources/reference.conf:
##########
@@ -1244,6 +1244,9 @@ pekko {
# Terminate the ActorSystem in the last phase actor-system-terminate.
terminate-actor-system = on
+ # The timeout that will be used when calling .close on an ActorSystem
Review Comment:
Same as https://github.com/apache/pekko/pull/2486#discussion_r2521369096, this is not part of public API
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@pekko.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@pekko.apache.org
For additional commands, e-mail: notifications-help@pekko.apache.org
Re: [PR] Add close on ActorSystem [pekko]
Posted by "mdedetrich (via GitHub)" <gi...@apache.org>.
mdedetrich commented on code in PR #2486:
URL: https://github.com/apache/pekko/pull/2486#discussion_r2522160353
##########
actor/src/main/resources/reference.conf:
##########
@@ -1244,6 +1244,9 @@ pekko {
# Terminate the ActorSystem in the last phase actor-system-terminate.
terminate-actor-system = on
+ # The timeout that will be used when calling .close on an ActorSystem
+ close-actor-system-timeout = 60 s
Review Comment:
1Day is way too much, people calling `close()` will expect it to do so in a reasonable time especially if they are doing it before a pod/server/instance is shutting down.
1 minute is a good default in my view
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@pekko.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@pekko.apache.org
For additional commands, e-mail: notifications-help@pekko.apache.org
Re: [PR] Add close on ActorSystem [pekko]
Posted by "He-Pin (via GitHub)" <gi...@apache.org>.
He-Pin commented on PR #2486:
URL: https://github.com/apache/pekko/pull/2486#issuecomment-3536702938
@mdedetrich feel free to merge this and send a backport to 1.3.x
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@pekko.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@pekko.apache.org
For additional commands, e-mail: notifications-help@pekko.apache.org
Re: [PR] Add close on ActorSystem [pekko]
Posted by "mdedetrich (via GitHub)" <gi...@apache.org>.
mdedetrich commented on PR #2486:
URL: https://github.com/apache/pekko/pull/2486#issuecomment-3524088728
> Does this PR also need to update [ActorSystemLifecycle.scala#L54](https://github.com/apache/pekko/blob/main/stream-tests-tck/src/test/scala/org/apache/pekko/stream/tck/ActorSystemLifecycle.scala#L54)?
So for this I would need an overloaded version of close with a duration i.e. `close(duration)` and that version would come after creating a `scaladsl/`javadsl` for `ActorSystem` since the `javadsl` will use a java duration and the `scaladsl` will use a scala duration.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@pekko.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@pekko.apache.org
For additional commands, e-mail: notifications-help@pekko.apache.org