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

Send + Sync Issues with list_containers #159

Open
Thrane20 opened this issue May 27, 2024 · 5 comments · May be fixed by #160
Open

Send + Sync Issues with list_containers #159

Thrane20 opened this issue May 27, 2024 · 5 comments · May be fixed by #160
Assignees

Comments

@Thrane20
Copy link

I have been using numerous dockworker methods inside my tokio / warp server, however one particular method never compiles under a tokio context, and that is ::list_containers

Spent quite a many, many hours trying to figure this out, but the error is:

"dyn for<'a> Fn(&'a str) -> Cow<'_, [u8]> cannot be shared between threads safely
the trait Sync is not implemented for dyn for<'a> Fn(&'a str) -> Cow<'_, [u8]>, which is required by impl Future<Output = Result<impl Reply, Infallible>>: Send" - for whenever this function is in the mix.

I've checked the dockworker code, and there's nothing specifically different here that's obviously problematic, however, the only different struct at play is ContainerFilters - but I can't see anything in there that would make Reply + Send incompatible.

Anyone else used dockworker inside a tokio context with no problems? I've exhausted all my investigations thus far...

DrWalrus1 added a commit to DrWalrus1/dockworker that referenced this issue Jun 10, 2024
Seemed to be related to passing the Serializer between threads
@DrWalrus1
Copy link

Did some digging around using a project I'm working on that uses Rocket. Seems like Serializer in this instance is not thread safe, need to wrap the param prep in a closure and return a thread safe string. Will figure out how to make a test for this and add it to my fork before opening a PR

@eldesh
Copy link
Collaborator

eldesh commented Jul 11, 2024

Thank you for reporting the issue. To help us better understand and resolve the problem, could you please provide a minimal, complete, and verifiable example of the code that reproduces the bug?

@DrWalrus1
Copy link

@eldesh you'll find a fix for this in this pr

This is an example that I altered in a commit: 46eedbe

Though to keep the code example not messy I removed it

@eldesh
Copy link
Collaborator

eldesh commented Jul 16, 2024

@DrWalrus1 If we cannot actually see the problem here, we cannot confirm the fix and therefore cannot incorporate the fix.
Can you show us the code that reproduces the problem?

@DrWalrus1
Copy link

DrWalrus1 commented Jul 17, 2024

@eldesh have coded up a small (broken) example here https://github.com/DrWalrus1/dockworker-fix-example.

This is how I ran into the problem.
Rocket seems to be spawning a tokio thread under the hood and when you call this method the call to serializer seems to be trying to be shared references across threads

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants