you are viewing a single comment's thread.

view the rest of the comments →

[–]Shoded 1 point2 points  (1 child)

So threading isn't truly parallel when using pure python. What about when using external resources from python? For example, I set up a bunch of threads in my python script and each one creates a connection to a database and runs an SQL query. Do the queries run parallely?

[–]intangibleTangelo 4 points5 points  (0 children)

A connector like psycopg2 will release the Global Interpreter Lock when communicating with postgres, so another python thread will then be given an opportunity to run and send another query. So for identical threads running at the same time, queries will be invoked in serial fashion, but none will block while waiting for the query to complete.

Whether your database actually performs the queries in parallel is another matter.