Skip to content
This repository has been archived by the owner on May 10, 2020. It is now read-only.

Make query inside warp framework call #88

Open
madmaxio opened this issue Dec 10, 2018 · 4 comments
Open

Make query inside warp framework call #88

madmaxio opened this issue Dec 10, 2018 · 4 comments

Comments

@madmaxio
Copy link

Trying to make query inside warp framework call, and failing with cannot block executor error. Warp is popular webframework https://github.com/seanmonstar/warp.
Perhaps i should pass a future with a query somehow?

@steffengy
Copy link
Owner

Do you have a more specific error, I can't quite find which crate returns a "cannot block executor" error?
I'm not sure which function should block, since everything should return a future - except if you're calling wait somehwere?

@brokenthorn
Copy link

He's probably waiting for the future's result in a main event loop, effectively blocking it for longer than allowed, which probably trips that error.

@madmaxio
Copy link
Author

Soory for such a late reply, check please this code for the idea of what I'm trying to do (it won't compile, it's the ideal scenario for web application workflow):

https://github.com/madmaxio/warp-tiberius

Basically:

Get warp request, use some input data for query, execute the future with DB request or a synchoronous DB request, return results to user.

@brokenthorn
Copy link

brokenthorn commented Feb 13, 2019

I've had the same issue before when I tried (for research) to mix warp and tiberius. The issues arises from warp. Its executor framework detects long running tasks inside handlers. It has a default timeout for this. Warp won't allow you to fetch data from a database and wait for that data inside its request handlers. That kind of stuff can take an arbitrarily long time to complete! You best bet would be to implement asynchronous processing. Inside the warp handler schedule a task to fetch the data you require and do that work in another thread, and notify the client of an URL it can regularly pool to get the results when they are ready or use some other method like websockets to notify the client when the data is ready.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants