Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is Python's "built-in method acquire"? How can I speed it up?

I'm writing a Python program with a lot of file access. It's running surprisingly slowly, so I used cProfile to find out what was taking the time.

It seems there's a lot of time spent in what Python is reporting as "{built-in method acquire}". I have no idea what this method is. What is it, and how can I speed up my program?

like image 447
Chris B. Avatar asked Feb 09 '09 21:02

Chris B.


1 Answers

Without seeing your code, it is hard to guess. But to guess I would say that it is the threading.Lock.acquire method. Part of your code is trying to get a threading lock, and it is waiting until it has got it.

There may be simple ways of fixing it by

  • restructuring your file access,
  • not locking,
  • using blocking=False,
  • or even not using threads at all.

But again, without seeing your code, it is hard to guess.

like image 188
Ali Afshar Avatar answered Jan 21 '23 10:01

Ali Afshar