Stopping Twitter streaming.

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

Stopping Twitter streaming.

seanparsons
I'm using the UserStream.open(...) approach shown in the Twine example project, but I can't immediately see any way of stopping the streaming.

Is there a way to stop it or will it just continue to process forever until the VM is stopped?
Reply | Threaded
Open this post in threaded view
|

Re: Stopping Twitter streaming.

n8han
Administrator
On 01/29/2011 07:51 PM, seanparsons [via Databinder] wrote:
> I'm using the UserStream.open(...) approach shown in the Twine example
> project, but I can't immediately see any way of stopping the streaming.
>
> Is there a way to stop it or will it just continue to process forever
> until the VM is stopped?

Or the thread it is running in. The current interface is blocking, so it
needs to be in its own thread for any real application. I am not sure
how cleanly the client will close the connection if you kill the thread,
perhaps you'll let the list know if you get that far with it.

I'm on the nio branch right now sorting through similar issues (still a
long way from a stable release of that) so any feedback on this stuff is
helpful.

Nathan
Reply | Threaded
Open this post in threaded view
|

Re: Stopping Twitter streaming.

n8han
Administrator
Found an answer to this:

"The trouble is Thread#interrupt() does not reliably interrupt blocking
I/O operations. The only truly reliable way to interrupt an I/O
operation is by shutting down the socket, which is what
HttpUriRequest#abort() does. "
http://old.nabble.com/Aborting-requests-via-Thread.interrupt()--td28569625.html

So, Dispatch will need to provide an interface to it.

Nathan
Reply | Threaded
Open this post in threaded view
|

Re: Stopping Twitter streaming.

n8han
Administrator
This has evolved on the 080 branch, works for blocking streams as well as nio. Twine is using nio, here's the diff:

https://github.com/n8han/dispatch-twine/commit/e34c14d6573a57da9acf4dcaafa43f30b5d44119