File tree Expand file tree Collapse file tree 4 files changed +20
-4
lines changed
Expand file tree Collapse file tree 4 files changed +20
-4
lines changed Original file line number Diff line number Diff line change @@ -260,8 +260,6 @@ def test_getdefaultencoding(self):
260260 # testing sys.settrace() is done in test_sys_settrace.py
261261 # testing sys.setprofile() is done in test_sys_setprofile.py
262262
263- # TODO: RUSTPYTHON, AttributeError: module 'sys' has no attribute 'setswitchinterval'
264- @unittest .expectedFailure
265263 def test_switchinterval (self ):
266264 self .assertRaises (TypeError , sys .setswitchinterval )
267265 self .assertRaises (TypeError , sys .setswitchinterval , "a" )
Original file line number Diff line number Diff line change @@ -55,8 +55,6 @@ def test_openlog_noargs(self):
5555 syslog .openlog ()
5656 syslog .syslog ('test message from python test_syslog' )
5757
58- # TODO: RUSTPYTHON; AttributeError: module 'sys' has no attribute 'getswitchinterval'
59- @unittest .expectedFailure
6058 @threading_helper .requires_working_threading ()
6159 def test_syslog_threaded (self ):
6260 start = threading .Event ()
Original file line number Diff line number Diff line change @@ -799,6 +799,24 @@ mod sys {
799799 crate :: vm:: thread:: COROUTINE_ORIGIN_TRACKING_DEPTH . with ( |cell| cell. get ( ) ) as _
800800 }
801801
802+ #[ pyfunction]
803+ fn getswitchinterval ( vm : & VirtualMachine ) -> f64 {
804+ // Return the stored switch interval
805+ vm. state . switch_interval . load ( )
806+ }
807+
808+ #[ pyfunction]
809+ fn setswitchinterval ( interval : f64 , vm : & VirtualMachine ) -> PyResult < ( ) > {
810+ // Validate the interval parameter like CPython does
811+ if interval <= 0.0 {
812+ return Err ( vm. new_value_error ( "switch interval must be strictly positive" . to_owned ( ) ) ) ;
813+ }
814+
815+ // Store the switch interval value
816+ vm. state . switch_interval . store ( interval) ;
817+ Ok ( ( ) )
818+ }
819+
802820 #[ derive( FromArgs ) ]
803821 struct SetAsyncgenHooksArgs {
804822 #[ pyarg( any, optional) ]
Original file line number Diff line number Diff line change @@ -106,6 +106,7 @@ pub struct PyGlobalState {
106106 pub after_forkers_child : PyMutex < Vec < PyObjectRef > > ,
107107 pub after_forkers_parent : PyMutex < Vec < PyObjectRef > > ,
108108 pub int_max_str_digits : AtomicCell < usize > ,
109+ pub switch_interval : AtomicCell < f64 > ,
109110}
110111
111112pub fn process_hash_secret_seed ( ) -> u32 {
@@ -189,6 +190,7 @@ impl VirtualMachine {
189190 after_forkers_child : PyMutex :: default ( ) ,
190191 after_forkers_parent : PyMutex :: default ( ) ,
191192 int_max_str_digits,
193+ switch_interval : AtomicCell :: new ( 0.005 ) ,
192194 } ) ,
193195 initialized : false ,
194196 recursion_depth : Cell :: new ( 0 ) ,
You can’t perform that action at this time.
0 commit comments