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

Parallel conversion to PyObject #58

Open
MusicalNinjaDad opened this issue Jun 10, 2024 · 1 comment
Open

Parallel conversion to PyObject #58

MusicalNinjaDad opened this issue Jun 10, 2024 · 1 comment
Assignees

Comments

@MusicalNinjaDad
Copy link
Owner

Newtype MyPyAny(Py(PyAny))
Impl MyPyAny into_mypy(FBAns, py)
IntoPy for MyPyAny

Add py token to fizzbuzz signature

.map FBAns -> FBAns.into_mypy(py)

@MusicalNinjaDad MusicalNinjaDad self-assigned this Jun 11, 2024
@MusicalNinjaDad
Copy link
Owner Author

error[E0277]: `*mut pyo3::Python<'static>` cannot be shared between threads safely
   --> rust/fizzbuzzo3/src/lib.rs:98:74
    |
98  |         FizzBuzzable::Vec(v) => Ok(FizzBuzzReturn::Many(v.fizzbuzz().map(|f: String| {f.into_py(py)}).collect())),
    |                                                                      --- -----------^^^^^^^^^^^^^^^^
    |                                                                      |   |
    |                                                                      |   `*mut pyo3::Python<'static>` cannot be shared between threads safely
    |                                                                      |   within this `{closure@rust/fizzbuzzo3/src/lib.rs:98:74: 98:85}`
    |                                                                      required by a bound introduced by this call
    |
    = help: within `{closure@rust/fizzbuzzo3/src/lib.rs:98:74: 98:85}`, the trait `Sync` is not implemented for `*mut pyo3::Python<'static>`, which is required by `{closure@rust/fizzbuzzo3/src/lib.rs:98:74: 98:85}: Sync`
note: required because it appears within the type `PhantomData<*mut pyo3::Python<'static>>`
   --> /opt/rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/marker.rs:740:12
    |
740 | pub struct PhantomData<T: ?Sized>;
    |            ^^^^^^^^^^^
note: required because it appears within the type `impl_::not_send::NotSend`
   --> /opt/cargo/registry/src/index.crates.io-6f17d22bba15001f/pyo3-0.21.2/src/impl_/not_send.rs:7:19
    |
7   | pub(crate) struct NotSend(PhantomData<*mut Python<'static>>);
    |                   ^^^^^^^
    = note: required because it appears within the type `(&pyo3::gil::GILGuard, impl_::not_send::NotSend)`
note: required because it appears within the type `PhantomData<(&pyo3::gil::GILGuard, impl_::not_send::NotSend)>`
   --> /opt/rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/marker.rs:740:12
    |
740 | pub struct PhantomData<T: ?Sized>;
    |            ^^^^^^^^^^^
note: required because it appears within the type `pyo3::Python<'_>`
   --> /opt/cargo/registry/src/index.crates.io-6f17d22bba15001f/pyo3-0.21.2/src/marker.rs:391:12
    |
391 | pub struct Python<'py>(PhantomData<(&'py GILGuard, NotSend)>);
    |            ^^^^^^
    = note: required because it appears within the type `&pyo3::Python<'_>`
note: required because it's used within this closure
   --> rust/fizzbuzzo3/src/lib.rs:98:74
    |
98  |         FizzBuzzable::Vec(v) => Ok(FizzBuzzReturn::Many(v.fizzbuzz().map(|f: String| {f.into_py(py)}).collect())),
    |                                                                          ^^^^^^^^^^^
note: required by a bound in `rayon::iter::ParallelIterator::map`
   --> /opt/cargo/registry/src/index.crates.io-6f17d22bba15001f/rayon-1.10.0/src/iter/mod.rs:603:34
    |
601 |     fn map<F, R>(self, map_op: F) -> Map<Self, F>
    |        --- required by a bound in this associated function
602 |     where
603 |         F: Fn(Self::Item) -> R + Sync + Send,
    |                                  ^^^^ required by this bound in `ParallelIterator::map`

For more information about this error, try `rustc --explain E0277`.
warning: `fizzbuzzo3` (lib test) generated 1 warning
error: could not compile `fizzbuzzo3` (lib test) due to 1 previous error; 1 warning emitted

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

No branches or pull requests

1 participant