Skip to content

Commit

Permalink
Replica is not Send (#25)
Browse files Browse the repository at this point in the history
The TC type `Replica` is legitimately not `Send`, because it embeds a
`Storge` implementation and that implementation may not be `Send`. In
fact, the SQLite implementation is not -- SQLite is single-threaded.

I think this is a reasonable restriction for the library for the moment.
If there is at some point a need to use a Replica from multiple threads,
then we can consider ways to lift this restriction safely.
  • Loading branch information
djmitche authored Jan 2, 2025
1 parent 2de83ed commit 4e702a9
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/replica.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,14 @@ use crate::{DependencyMap, Operations, Task, WorkingSet};
use pyo3::prelude::*;
use taskchampion::{Replica as TCReplica, ServerConfig, StorageConfig, Uuid};

#[pyclass]
#[pyclass(unsendable)]
/// A replica represents an instance of a user's task data, providing an easy interface
/// for querying and modifying that data.
///
/// A replica can only be used in the thread in which it was created. Use from any other
/// thread will panic.
pub struct Replica(TCReplica);

unsafe impl Send for Replica {}
#[pymethods]
impl Replica {
#[staticmethod]
Expand Down

0 comments on commit 4e702a9

Please sign in to comment.