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

Running Netty server object unprintable #246

Closed
cemerick opened this issue May 4, 2016 · 1 comment
Closed

Running Netty server object unprintable #246

cemerick opened this issue May 4, 2016 · 1 comment

Comments

@cemerick
Copy link

cemerick commented May 4, 2016

As of 8d11ad7, the object returned by aleph.http/start-server cannot be printed (usually at the REPL, but ofc a possibility in other contexts) without blocking, until the server is closed. Not a problem, but perhaps surprising, and maybe tricky to track down if e.g. someone happens to put a server object in a map or something which then gets logged.

I see a couple of options. An IPending impl could be added to the reified object, like:

clojure.lang.IPending
(isRealized [_]
  (and (-> ch .closeFuture .isDone)
    (-> group .terminationFuture .isDone)))

Gets the job done, but not really in the spirit of IPending, realized?, etc. The more principled and functional approach would be to swap out IDeref for IBlockingDeref; this would fix the printing problem, and also let (uh, force?) people using the deref-to-wait-for-server-close feature avail themselves of a timeout. The only downside AFAICT is that you couldn't just @server to wait. The equivalent would be (deref server Long/MAX_VALUE nil).

@ztellman
Copy link
Collaborator

ztellman commented May 4, 2016

Balls, I forgot about auto deref on print. Let me think about this a bit
more.
On Wed, May 4, 2016 at 3:10 AM Chas Emerick notifications@github.com
wrote:

As of 8d11ad7
8d11ad7,
the object returned by aleph.http/start-server cannot be printed (usually
at the REPL, but ofc a possibility in other contexts) without blocking,
until the server is closed. Not a problem, but perhaps surprising, and
maybe tricky to track down if e.g. someone happens to put a server object
in a map or something which then gets logged.

I see a couple of options. An IPending impl could be added to the reified
object, like:

clojure.lang.IPending
(isRealized [_](and %28-> ch .closeFuture .isDone%29
%28-> group .terminationFuture .isDone%29))

Gets the job done, but not really in the spirit of IPending, realized?,
etc. The more principled and functional approach would be to swap out
IDeref for IBlockingDeref; this would fix the printing problem, and also
let (uh, force?) people using the deref-to-wait-for-server-close feature
avail themselves of a timeout. The only downside AFAICT is that you
couldn't just @server to wait. The equivalent would be (deref server
Long/MAX_VALUE nil).


You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub
#246

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

No branches or pull requests

2 participants