3

Is it possible to acquire the global interpreter lock from python code? Or is that purely implemented in the C side?

Falmarri
  • 47,727
  • 41
  • 151
  • 191

1 Answers1

7

If your code executes then you have the GIL, no need to acquire it manually.

Marek Sapota
  • 20,103
  • 3
  • 34
  • 47
  • Right; there is no need to ever mess with the GIL. – Rafe Kettler Jan 31 '11 at 20:48
  • 2
    There are times when you need to do transactions (multiple commands without thread-switching). How can I guarantee this if not without explicit acquisition of the GIL? – Asclepius Nov 17 '12 at 01:07
  • If you can not do this with locks/semaphores or other things from the `threading` module you are probably doing something wrong. – Marek Sapota Dec 07 '12 at 23:01