Skip to content

Commit f84db76

Browse files
committed
Disable atfork callback in tokenizers
1 parent fe06e1f commit f84db76

File tree

2 files changed

+56
-0
lines changed

2 files changed

+56
-0
lines changed

graalpython/lib-graalpython/patches/tokenizers/tokenizers-0.13.3.patch

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,34 @@ index 6282c31..47e6b12 100644
2222

2323
[features]
2424
default = ["pyo3/extension-module"]
25+
diff --git a/src/lib.rs b/src/lib.rs
26+
index bf1adbd..89c34fe 100644
27+
--- a/src/lib.rs
28+
+++ b/src/lib.rs
29+
@@ -48,14 +48,16 @@ extern "C" fn child_after_fork() {
30+
pub fn tokenizers(_py: Python, m: &PyModule) -> PyResult<()> {
31+
let _ = env_logger::try_init_from_env("TOKENIZERS_LOG");
32+
33+
+ // GraalPy change: Disable the atfork warning. This triggers a ton of false positives when
34+
+ // jline calls stty and we don't support fork anyway
35+
// Register the fork callback
36+
- #[cfg(target_family = "unix")]
37+
- unsafe {
38+
- if !REGISTERED_FORK_CALLBACK {
39+
- libc::pthread_atfork(None, None, Some(child_after_fork));
40+
- REGISTERED_FORK_CALLBACK = true;
41+
- }
42+
- }
43+
+ // #[cfg(target_family = "unix")]
44+
+ // unsafe {
45+
+ // if !REGISTERED_FORK_CALLBACK {
46+
+ // libc::pthread_atfork(None, None, Some(child_after_fork));
47+
+ // REGISTERED_FORK_CALLBACK = true;
48+
+ // }
49+
+ // }
50+
51+
m.add_class::<tokenizer::PyTokenizer>()?;
52+
m.add_class::<tokenizer::PyAddedToken>()?;
2553
diff --git a/tokenizers-lib/src/models/bpe/trainer.rs b/tokenizers-lib/src/models/bpe/trainer.rs
2654
index 43ab848..55f95f8 100644
2755
--- a/tokenizers-lib/src/models/bpe/trainer.rs

graalpython/lib-graalpython/patches/tokenizers/tokenizers-0.15.0.patch

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,3 +22,31 @@ index 51ac712..a7d1e9b 100644
2222

2323
[features]
2424
defaut = ["pyo3/extension-module"]
25+
diff --git a/bindings/python/src/lib.rs b/bindings/python/src/lib.rs
26+
index 8625944..a8ac19d 100644
27+
--- a/bindings/python/src/lib.rs
28+
+++ b/bindings/python/src/lib.rs
29+
@@ -50,14 +50,16 @@ extern "C" fn child_after_fork() {
30+
pub fn tokenizers(_py: Python, m: &PyModule) -> PyResult<()> {
31+
let _ = env_logger::try_init_from_env("TOKENIZERS_LOG");
32+
33+
+ // GraalPy change: Disable the atfork warning. This triggers a ton of false positives when
34+
+ // jline calls stty and we don't support fork anyway
35+
// Register the fork callback
36+
- #[cfg(target_family = "unix")]
37+
- unsafe {
38+
- if !REGISTERED_FORK_CALLBACK {
39+
- libc::pthread_atfork(None, None, Some(child_after_fork));
40+
- REGISTERED_FORK_CALLBACK = true;
41+
- }
42+
- }
43+
+ // #[cfg(target_family = "unix")]
44+
+ // unsafe {
45+
+ // if !REGISTERED_FORK_CALLBACK {
46+
+ // libc::pthread_atfork(None, None, Some(child_after_fork));
47+
+ // REGISTERED_FORK_CALLBACK = true;
48+
+ // }
49+
+ // }
50+
51+
m.add_class::<tokenizer::PyTokenizer>()?;
52+
m.add_class::<tokenizer::PyAddedToken>()?;

0 commit comments

Comments
 (0)