.. _useless-with-lock:

useless-with-lock / W2101
=========================

**Message emitted:**

'%s()' directly created in 'with' has no effect

**Description:**

*Used when a new lock instance is created by using with statement which has no effect. Instead, an existing instance should be used to acquire lock.*


**Correct code:**

.. literalinclude:: /data/messages/u/useless-with-lock/good.py
   :language: python

**Additional details:**

You can help us make the doc better `by contributing <https://github.com/PyCQA/pylint/issues/5953>`_ !


Created by the `threading <https://github.com/PyCQA/pylint/blob/main/pylint/checkers/threading_checker.py>`__ checker.