3

I am using twisted with MySQL using the adbapi connection pool. I only insert into my database (although at very fast rate).

What happens if the connection pool runs out of connections because all connections are busy? Will the twisted event loop be blocked when calling runinteraction on a busy connection pool?

icedtrees
  • 6,134
  • 5
  • 25
  • 35
artn3r
  • 31
  • 1

1 Answers1

0

tl;dr Calling RunInteraction will return a Deferred, and will not block.

Basically, it returns thread.deferToThreadPool

Which returns a Deferred after calling threadpool.callInThreadWithCallback

And that function calls: self._team.do(inContext), where _team gets created here

...and after even more abstractions, we eventually get to the point where it just appends the request to a queue of pending tasks when it runs out of workers (connections)

So your inserts will eventually make it to the database (unless, and until the process runs out of memory when there are too many tasks on the pending list)

Gerrat
  • 28,863
  • 9
  • 73
  • 101