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

Add support of a custom executor #67

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Conversation

blackbeam
Copy link
Owner

This PR adds support of a custom executors (defaults to tokio::executor::DefaultExecutor).

Required bounds for supported executors are defined as MyExecutor trait.

New constructors:

  • Conn::with_executor
  • Conn::from_url_with_executor
  • Pool::with_executor
  • Pool::from_url_with_executor

Changes to existing code should be minimal because of default value for new type parameter on Pool and Conn.

@blackbeam
Copy link
Owner Author

@PvdBerg1998, could you please test this branch with your executor?

@PvdBerg1998
Copy link

Looks great! I'll test it now.

@PvdBerg1998
Copy link

I have a question: what happens when the Pool is dropped? Are existing connections dropped immediately? Because requiring the Executor in drop would mean trouble for my usecase and I think it's weird to do so. Or are the connections only cleaned up when manually calling disconnect?

@PvdBerg1998
Copy link

PvdBerg1998 commented Jul 13, 2019

The same concern I have about this function:

fn disconnect<E: crate::MyExecutor>(mut conn: Conn<E>) {

Also, this still is hardcoded to use tokio.

Edit: I think the disconnection should just be done in a blocking way inside Drop.

@PvdBerg1998
Copy link

I found something weird: my process does not exit after main finishes? Details:

  1. The executor is halted, so it will fail to spawn a future.
  2. The database pool is dropped at the end of main
  3. Perhaps something is waiting forever inside a drop impl?

@PvdBerg1998
Copy link

I found the issue: I have a wrapping type around a Pool, with a Drop impl that does this:

let _ = block_on(self.pool.clone().disconnect().compat());

Apparently this blocks forever when the executor is halted. Any idea how this could be prevented?

@PvdBerg1998
Copy link

@blackbeam I would really like to fix this issue. Just fyi the PR most likely breaks something (or, hopefully, I'm doing something wrong) so it shouldn't be merged yet. If we wait until async await is stable and tokio is updated, I can move back to using tokio and this is no longer an issue. Still it is a nice flexibility feature but I expect tokio to get used most of the time

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

Successfully merging this pull request may close these issues.

2 participants