Promise never completes if not looked at?

83 views
Skip to first unread message

Peter Robinett

unread,
Apr 3, 2013, 6:48:49 AM4/3/13
to dispatc...@googlegroups.com
I have the following code: Http(uri OK as.String).either. I'm just calling a method that contains it and ignoring the resulting promise, since I can't handle the return values yet. However, then the request never gets made.

If I println the returned promise, however, the request gets made and everything's fine. Why is this? Is Dispatch doing something where it refuses to execute the request if there are no completion handlers?

If it helps, this is within the context of a Lift RestHelper response...

Thanks,
Peter

Nathan Hamblen

unread,
Apr 3, 2013, 8:21:40 AM4/3/13
to dispatc...@googlegroups.com
On 04/03/2013 06:48 AM, Peter Robinett wrote:
I have the following code: Http(uri OK as.String).either. I'm just calling a method that contains it and ignoring the resulting promise, since I can't handle the return values yet. However, then the request never gets made.

Right, I think Doug ran into this a few weeks back. It would have been introduced when I removed most of the future listeners to reduce contention on the lazy result val when it completes.

0.10 is pretty close and will fix the problem by using a Scala promise as the underlying mechanism, but would you mind opening an issue so it's documented? We may also want to fix in 0.9 since the upgrade has breaking changes that may take people a while to adapt to.

Nathan

Doug Tangren

unread,
Apr 3, 2013, 8:26:13 AM4/3/13
to dispatc...@googlegroups.com


-Doug Tangren
http://lessis.me


Work around if your stuck, just call `map(identity)` on the promise

// dispatch 0.9.5 won't apply handler unless results of promise are mapped over
 http(request > handler).map(identity)

This forces dispatch to register the listener associated with the request handler.

 
Nathan

--
You received this message because you are subscribed to the Google Groups "Dispatch" group.
To unsubscribe from this group and stop receiving emails from it, send an email to dispatch-scal...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

Peter Robinett

unread,
Apr 3, 2013, 8:30:34 AM4/3/13
to dispatc...@googlegroups.com
Cool, thanks Doug.

Peter

Peter Robinett

unread,
Apr 3, 2013, 9:09:45 AM4/3/13
to dispatc...@googlegroups.com
Sure, Nathan, here's the issue: https://github.com/dispatch/reboot/issues/50

Tobias Pfeiffer

unread,
Aug 8, 2013, 12:06:50 PM8/8/13
to dispatc...@googlegroups.com
Hi,

Am 03.04.2013 21:26, schrieb Doug Tangren:
> Work around if your stuck, just call `map(identity)` on the promise
>
> // dispatch 0.9.5 won't apply handler unless results of promise are
> mapped over http(request > handler).map(identity)
>
> This forces dispatch to register the listener associated with the
> request handler.

I just ran into this as well and unfortunately this workaround doesn't
work for me... situation doesn't change, even when doing map(identity).
As I don't have the time right now to check for possible
incompatiblities with newer dispatch versions, I ended up doing

val res = Http(...)
future {
res.apply()
}

Veeeery ugly, though...

Tobias

signature.asc
Reply all
Reply to author
Forward
0 new messages