Python has two GILs
Itis bit silly that code executing in one thread could fail because at the timethat it tries to call time.strptime() a different thread has the global import lock.
Pythonhas another GIL? Someone call Beazley.
Latelyonce or twice a week I've been seeing a request fail from one of my wsgiworkers (multiprocess, multithreaded). The exception looks like this:
Apparentlythere's some "interesting" stuff that happens for a number ofmodules. If you have more than one thread racing to format dates before_strptime has been imported in that process for instance, all but one of thosethreads may get an ImportError.
Workaroundsall basically involve some version of manually importing modules like thisbefore letting threads do work. The WSGIImportDirective appears to make thispretty easy if you're confident about which modules you care about. (The original ticket, filed against modwsgi is also an interestingread)
I'm far from an expert when it comes to python (especially CPython internals!), butI found this little tidbit more than a little bit surprising.
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/301743/viewspace-730271/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- What happens when exadata has lost two disks?(轉)APP
- Linguistics-English-Time is money + A coin has two sides.NGUIIDE
- python: leetcode - 1 Two SumPythonLeetCode
- Add_Two_Numbers python 求解Python
- coca after two months vs in two months
- python leetcode 之兩數之和(two sum)PythonLeetCode
- jQuery has()jQuery
- jQuery :has()jQuery
- oracle hasOracle
- Python, pandas: how to sort dataframe by index// Merge two dataframes by indexPythonIndex
- a tale of two cities
- Two extremes in lifeREM
- Two Pirates - 2
- LeetCode-two sum:python解答陣列問題LeetCodePython陣列
- AttributeError: 'dict' object has no attribute 'has_key'ErrorObject
- [CSS 3] :has()CSS
- 20171211 查詢+心得Map two lists into a dictionary in PythonPython
- Two Types of Error in JAVAErrorJava
- Divide Two IntegersIDE
- Enqueue events part twoENQ
- F - Two Sequence Queries
- Tokitsukaze and Two Colorful Tapes
- oracle has a disk HB, but no network HB, DHB has r cfg , wrtcntOracle
- 【Oracle】-【TWO_TASK】-TWO_TASK環境變數的作用Oracle變數
- yarn certificate has expiredYarn
- Study for Go ! Chapter two - ExpressionGoAPTExpress
- Leetcode Two SumLeetCode
- Leetcode Power of TwoLeetCode
- B. Two Out of Three
- MySQL server has gone awayMySqlServerGo
- python去掉excel空格和換行,報錯'int' object has no attribute 'strip'PythonExcelObject
- RuntimeError: An attempt has been made to start a new process before the current process hasError
- leetcode 兩數相加(add two numbers) Python程式設計實現LeetCodePython程式設計
- React Demo Two - TodoList 升級React
- Leetcode 1 two sumLeetCode
- A - Yet Another Two Integers Problem ACMACM
- Two useful scenarios of git stashiOSGit
- iOS面試題·自整理·TwoiOS面試題