-
Notifications
You must be signed in to change notification settings - Fork 433
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
feat: allow multiple Python threads to work with a single DeltaTable instance #3101
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #3101 +/- ##
==========================================
- Coverage 72.52% 72.38% -0.15%
==========================================
Files 128 128
Lines 41201 41296 +95
Branches 41201 41296 +95
==========================================
+ Hits 29882 29892 +10
- Misses 9408 9499 +91
+ Partials 1911 1905 -6 ☔ View full report in Codecov by Sentry. |
3acb36f
to
3804d51
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
looking good!
just some very minor cleanup that you may want to consider?
python/src/lib.rs
Outdated
Err(e) => Err(e), | ||
} | ||
.expect("SHOOT!"); | ||
// TODO: XXX |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
artifact?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
d'oh! good catch, I did miss some of this junk in my diff review before poooshing
python/src/lib.rs
Outdated
.map_err(PythonError::from) | ||
.map_err(PyErr::from) | ||
})?; | ||
//.map_err(|_| DeltaProtocolError::new_err("table does not yet have a schema"))? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can we remove this?
…instance This change introduces an internal Mutex inside of RawDeltaTable which allows the PyO3 bindings to share the Python object between threads at the Python layer. PyO3 will raise a `RuntimeError: Already borrowed` for any function call which takes a mutable reference to `self`. Introducing the internal Mutex ensures that all function signatures can operate with just self-references safely. The Rust-level Mutex is a simple passthrough for most operations which do not need to modify the underlying state. The critical sections which typically need to acquire and mutate with a lock are after I/O bound operations are completed as far as I can tell, so I don't anticipate deadlock or performance issues. There is still some cleanup of errors that needs to happen to make the code here more ergonomic when blending DeltaError with PoisonError from the lock, as such right now there's a lot of ugly error mapping. Fixes delta-io#2958 Signed-off-by: R. Tyler Croy <[email protected]> Sponsored-by: Neuralink Corp.
3804d51
to
9848ffb
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
This change introduces an internal Mutex inside of RawDeltaTable which allows the PyO3 bindings to share the Python object between threads at the Python layer.
PyO3 will raise a
RuntimeError: Already borrowed
for any function call which takes a mutable reference toself
. Introducing the internal Mutex ensures that all function signatures can operate with just self-references safely.The Rust-level Mutex is a simple passthrough for most operations which do not need to modify the underlying state. The critical sections which typically need to acquire and mutate with a lock are after I/O bound operations are completed as far as I can tell, so I don't anticipate deadlock or performance issues.
There is still some cleanup of errors that needs to happen to make the code here more ergonomic when blending DeltaError with PoisonError from the lock, as such right now there's a lot of ugly error mapping.
Fixes #2958