CAPI and thread safety

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Lane Brooks

    CAPI and thread safety

    I am writing an extension module that needs to release the global
    interpreter lock during some blocking I/O calls, but I need a mutex in
    the C code to make some of the shared data in the extension module are
    kept thread safe. Can anyone recommend a portable way to do this? I
    could use a pthread mutex, but I do not think that is portable.

    Are any of the python mutexes or locks exposed through the C API? I
    could not find anything.

    Thanks,
    Lane
  • Benjamin

    #2
    Re: CAPI and thread safety

    On Jun 27, 4:33 pm, Lane Brooks <l...@ubixum.co mwrote:
    I am writing an extension module that needs to release the global
    interpreter lock during some blocking I/O calls, but I need a mutex in
    the C code to make some of the shared data in the extension module are
    kept thread safe.  Can anyone recommend a portable way to do this?  I
    could use a pthread mutex, but I do not think that is portable.
    >
    Are any of the python mutexes or locks exposed through the C API?  I
    could not find anything.
    Look at Include/pythread.h. You can use PyThread_alloca te_lock to get
    the threading abstractions that Python uses.
    >
    Thanks,
    Lane

    Comment

    • Lane Brooks

      #3
      Re: CAPI and thread safety

      Thanks for the pointer. I'll check it out. That is what I was looking
      for.

      Lane

      Benjamin wrote:
      On Jun 27, 4:33 pm, Lane Brooks <l...@ubixum.co mwrote:
      >
      >I am writing an extension module that needs to release the global
      >interpreter lock during some blocking I/O calls, but I need a mutex in
      >the C code to make some of the shared data in the extension module are
      >kept thread safe. Can anyone recommend a portable way to do this? I
      >could use a pthread mutex, but I do not think that is portable.
      >>
      >Are any of the python mutexes or locks exposed through the C API? I
      >could not find anything.
      >>
      >
      Look at Include/pythread.h. You can use PyThread_alloca te_lock to get
      the threading abstractions that Python uses.
      >
      >
      >Thanks,
      >Lane
      >>
      >
      --

      >

      Comment

      Working...