diff --git a/persistqueue/queue.py b/persistqueue/queue.py
index dac8ec6..0a1e301 100644
--- a/persistqueue/queue.py
+++ b/persistqueue/queue.py
@@ -138,6 +138,9 @@ class Queue(object):
     def _qsize(self):
         return self.info['size']
 
+    def empty(self):
+        return self.qsize() == 0
+
     def put(self, item, block=True, timeout=None):
         "Interface for putting item in disk-based queue."
         self.not_full.acquire()
diff --git a/persistqueue/sqlackqueue.py b/persistqueue/sqlackqueue.py
index d91c033..45ea0f4 100644
--- a/persistqueue/sqlackqueue.py
+++ b/persistqueue/sqlackqueue.py
@@ -215,6 +215,9 @@ class SQLiteAckQueue(sqlbase.SQLiteBase):
     def qsize(self):
         return self.size
 
+    def empty(self):
+        return self.size == 0
+
     def __len__(self):
         return self.size
 
diff --git a/persistqueue/sqlqueue.py b/persistqueue/sqlqueue.py
index 1471b04..f01eec7 100644
--- a/persistqueue/sqlqueue.py
+++ b/persistqueue/sqlqueue.py
@@ -115,6 +115,9 @@ class SQLiteQueue(sqlbase.SQLiteBase):
     def qsize(self):
         return self.size
 
+    def empty(self):
+        return self.size == 0
+
     def __len__(self):
         return self.size
 

Add #.empty
Hello @peter-wangxu, would you accept a PR adding the #.empty method to your queue implementations?

We could also add #.full but since the SQLite queue does not support `maxsize` I guess it would not make much sense.
diff --git a/persistqueue/tests/test_queue.py b/persistqueue/tests/test_queue.py
index a6b69c8..f528ba3 100644
--- a/persistqueue/tests/test_queue.py
+++ b/persistqueue/tests/test_queue.py
@@ -46,6 +46,16 @@ class PersistTest(unittest.TestCase):
         q.task_done()
         del q
 
+    def test_empty(self):
+        q = Queue(self.path)
+        self.assertEqual(q.empty(), True)
+
+        q.put('var1')
+        self.assertEqual(q.empty(), False)
+
+        q.get()
+        self.assertEqual(q.empty(), True)
+
     @params(*serializer_params)
     def test_open_close_1000(self, serializer):
         """Write 1000 items, close, reopen checking if all items are there"""
diff --git a/persistqueue/tests/test_sqlackqueue.py b/persistqueue/tests/test_sqlackqueue.py
index 465a675..2914eec 100644
--- a/persistqueue/tests/test_sqlackqueue.py
+++ b/persistqueue/tests/test_sqlackqueue.py
@@ -35,6 +35,16 @@ class SQLite3AckQueueTest(unittest.TestCase):
         # assert with negative timeout
         self.assertRaises(ValueError, q.get, block=True, timeout=-1.0)
 
+    def test_empty(self):
+        q = SQLiteAckQueue(self.path, auto_commit=self.auto_commit)
+        self.assertEqual(q.empty(), True)
+
+        q.put('first')
+        self.assertEqual(q.empty(), False)
+
+        q.get()
+        self.assertEqual(q.empty(), True)
+
     def test_open_close_single(self):
         """Write 1 item, close, reopen checking if same item is there"""
 
diff --git a/persistqueue/tests/test_sqlqueue.py b/persistqueue/tests/test_sqlqueue.py
index a2fdaef..d71d661 100644
--- a/persistqueue/tests/test_sqlqueue.py
+++ b/persistqueue/tests/test_sqlqueue.py
@@ -36,6 +36,16 @@ class SQLite3QueueTest(unittest.TestCase):
         self.assertRaises(ValueError, q.get, block=True, timeout=-1.0)
         del q
 
+    def test_empty(self):
+        q = SQLiteQueue(self.path, auto_commit=self.auto_commit)
+        self.assertEqual(q.empty(), True)
+
+        q.put('first')
+        self.assertEqual(q.empty(), False)
+
+        q.get()
+        self.assertEqual(q.empty(), True)
+
     def test_open_close_single(self):
         """Write 1 item, close, reopen checking if same item is there"""
 

pip install -e .[extra]
parse_log_pytest
requirements.txt
nose2 mock flake8 eventlet msgpack coverage cov_core virtualenv pytest
3.9
extra-requirements.txt
pytest --no-header -rA --tb=line --color=no -p no:cacheprovider -W ignore::DeprecationWarning
cov-core==1.15.0
coverage==7.8.0
distlib==0.3.9
dnspython==2.7.0
eventlet==0.39.1
exceptiongroup==1.2.2
filelock==3.18.0
flake8==7.2.0
greenlet==3.1.1
iniconfig==2.1.0
mccabe==0.7.0
mock==5.2.0
msgpack==1.1.0
nose2==0.15.1
packaging==24.2
-e git+https://github.com/peter-wangxu/persist-queue.git@bff90abfae0011427de552bb0243d521d6fa79ce#egg=persist_queue
platformdirs==4.3.7
pluggy==1.5.0
pycodestyle==2.13.0
pyflakes==3.3.1
pytest==8.3.5
tomli==2.2.1
virtualenv==20.29.3

name: persist-queue
channels:
  - defaults
  - https://repo.anaconda.com/pkgs/main
  - https://repo.anaconda.com/pkgs/r
  - conda-forge
dependencies:
  - _libgcc_mutex=0.1=main
  - _openmp_mutex=5.1=1_gnu
  - ca-certificates=2025.2.25=h06a4308_0
  - ld_impl_linux-64=2.40=h12ee557_0
  - libffi=3.4.4=h6a678d5_1
  - libgcc-ng=11.2.0=h1234567_1
  - libgomp=11.2.0=h1234567_1
  - libstdcxx-ng=11.2.0=h1234567_1
  - ncurses=6.4=h6a678d5_0
  - openssl=3.0.16=h5eee18b_0
  - pip=25.0=py39h06a4308_0
  - python=3.9.21=he870216_1
  - readline=8.2=h5eee18b_0
  - setuptools=75.8.0=py39h06a4308_0
  - sqlite=3.45.3=h5eee18b_0
  - tk=8.6.14=h39e8969_0
  - tzdata=2025a=h04d1e81_0
  - wheel=0.45.1=py39h06a4308_0
  - xz=5.6.4=h5eee18b_1
  - zlib=1.2.13=h5eee18b_1
  - pip:
      - cov-core==1.15.0
      - coverage==7.8.0
      - distlib==0.3.9
      - dnspython==2.7.0
      - eventlet==0.39.1
      - exceptiongroup==1.2.2
      - filelock==3.18.0
      - flake8==7.2.0
      - greenlet==3.1.1
      - iniconfig==2.1.0
      - mccabe==0.7.0
      - mock==5.2.0
      - msgpack==1.1.0
      - nose2==0.15.1
      - packaging==24.2
      - platformdirs==4.3.7
      - pluggy==1.5.0
      - pycodestyle==2.13.0
      - pyflakes==3.3.1
      - pytest==8.3.5
      - tomli==2.2.1
      - virtualenv==20.29.3
prefix: /opt/conda/envs/persist-queue

persistqueue/tests/test_queue.py::PersistTest::test_empty persistqueue/tests/test_sqlackqueue.py::SQLite3AckQueueTest::test_empty persistqueue/tests/test_sqlackqueue.py::SQLite3QueueInMemory::test_empty persistqueue/tests/test_sqlqueue.py::SQLite3QueueTest::test_empty persistqueue/tests/test_sqlqueue.py::SQLite3QueueNoAutoCommitTest::test_empty persistqueue/tests/test_sqlqueue.py::SQLite3QueueInMemory::test_empty
persistqueue/tests/test_queue.py::PersistTest::test_clear_tail_file persistqueue/tests/test_queue.py::PersistTest::test_garbage_on_head persistqueue/tests/test_queue.py::PersistTest::test_get_timeout persistqueue/tests/test_queue.py::PersistTest::test_get_timeout_negative persistqueue/tests/test_queue.py::PersistTest::test_multi_threaded persistqueue/tests/test_queue.py::PersistTest::test_open_close_1000 persistqueue/tests/test_queue.py::PersistTest::test_open_close_single persistqueue/tests/test_queue.py::PersistTest::test_partial_write persistqueue/tests/test_queue.py::PersistTest::test_put_block_and_wait persistqueue/tests/test_queue.py::PersistTest::test_put_maxsize_reached persistqueue/tests/test_queue.py::PersistTest::test_put_nowait persistqueue/tests/test_queue.py::PersistTest::test_put_timeout_negative persistqueue/tests/test_queue.py::PersistTest::test_put_timeout_reached persistqueue/tests/test_queue.py::PersistTest::test_random_read_write persistqueue/tests/test_queue.py::PersistTest::test_task_done_too_many_times
persistqueue/tests/test_queue.py::PersistTest::test_protocol persistqueue/tests/test_sqlackqueue.py::SQLite3AckQueueTest::test_ack_and_clear persistqueue/tests/test_sqlackqueue.py::SQLite3AckQueueTest::test_ack_unack_ack_failed persistqueue/tests/test_sqlackqueue.py::SQLite3AckQueueTest::test_ack_unknown_item persistqueue/tests/test_sqlackqueue.py::SQLite3AckQueueTest::test_multi_threaded_multi_producer persistqueue/tests/test_sqlackqueue.py::SQLite3AckQueueTest::test_multi_threaded_parallel persistqueue/tests/test_sqlackqueue.py::SQLite3AckQueueTest::test_multiple_consumers persistqueue/tests/test_sqlackqueue.py::SQLite3AckQueueTest::test_open_close_1000 persistqueue/tests/test_sqlackqueue.py::SQLite3AckQueueTest::test_open_close_single persistqueue/tests/test_sqlackqueue.py::SQLite3AckQueueTest::test_protocol_1 persistqueue/tests/test_sqlackqueue.py::SQLite3AckQueueTest::test_protocol_2 persistqueue/tests/test_sqlackqueue.py::SQLite3AckQueueTest::test_put_0 persistqueue/tests/test_sqlackqueue.py::SQLite3AckQueueTest::test_raise_empty persistqueue/tests/test_sqlackqueue.py::SQLite3AckQueueTest::test_random_read_write persistqueue/tests/test_sqlackqueue.py::SQLite3AckQueueTest::test_resume_unack persistqueue/tests/test_sqlackqueue.py::SQLite3QueueInMemory::test_ack_and_clear persistqueue/tests/test_sqlackqueue.py::SQLite3QueueInMemory::test_ack_unack_ack_failed persistqueue/tests/test_sqlackqueue.py::SQLite3QueueInMemory::test_ack_unknown_item persistqueue/tests/test_sqlackqueue.py::SQLite3QueueInMemory::test_protocol_1 persistqueue/tests/test_sqlackqueue.py::SQLite3QueueInMemory::test_put_0 persistqueue/tests/test_sqlackqueue.py::SQLite3QueueInMemory::test_raise_empty persistqueue/tests/test_sqlackqueue.py::SQLite3QueueInMemory::test_random_read_write persistqueue/tests/test_sqlackqueue.py::FILOSQLite3AckQueueTest::test_open_close_1000 persistqueue/tests/test_sqlackqueue.py::SQLite3UniqueAckQueueTest::test_add_duplicate_item persistqueue/tests/test_sqlqueue.py::SQLite3QueueTest::test_json_serializer persistqueue/tests/test_sqlqueue.py::SQLite3QueueTest::test_multi_threaded_multi_producer persistqueue/tests/test_sqlqueue.py::SQLite3QueueTest::test_multi_threaded_parallel persistqueue/tests/test_sqlqueue.py::SQLite3QueueTest::test_multiple_consumers persistqueue/tests/test_sqlqueue.py::SQLite3QueueTest::test_open_close_1000 persistqueue/tests/test_sqlqueue.py::SQLite3QueueTest::test_open_close_single persistqueue/tests/test_sqlqueue.py::SQLite3QueueTest::test_protocol_1 persistqueue/tests/test_sqlqueue.py::SQLite3QueueTest::test_protocol_2 persistqueue/tests/test_sqlqueue.py::SQLite3QueueTest::test_put_0 persistqueue/tests/test_sqlqueue.py::SQLite3QueueTest::test_raise_empty persistqueue/tests/test_sqlqueue.py::SQLite3QueueTest::test_random_read_write persistqueue/tests/test_sqlqueue.py::SQLite3QueueTest::test_task_done_with_restart persistqueue/tests/test_sqlqueue.py::SQLite3QueueNoAutoCommitTest::test_json_serializer persistqueue/tests/test_sqlqueue.py::SQLite3QueueNoAutoCommitTest::test_multi_threaded_multi_producer persistqueue/tests/test_sqlqueue.py::SQLite3QueueNoAutoCommitTest::test_multi_threaded_parallel persistqueue/tests/test_sqlqueue.py::SQLite3QueueNoAutoCommitTest::test_open_close_1000 persistqueue/tests/test_sqlqueue.py::SQLite3QueueNoAutoCommitTest::test_open_close_single persistqueue/tests/test_sqlqueue.py::SQLite3QueueNoAutoCommitTest::test_protocol_1 persistqueue/tests/test_sqlqueue.py::SQLite3QueueNoAutoCommitTest::test_protocol_2 persistqueue/tests/test_sqlqueue.py::SQLite3QueueNoAutoCommitTest::test_put_0 persistqueue/tests/test_sqlqueue.py::SQLite3QueueNoAutoCommitTest::test_raise_empty persistqueue/tests/test_sqlqueue.py::SQLite3QueueNoAutoCommitTest::test_random_read_write persistqueue/tests/test_sqlqueue.py::SQLite3QueueNoAutoCommitTest::test_task_done_with_restart persistqueue/tests/test_sqlqueue.py::SQLite3QueueInMemory::test_json_serializer persistqueue/tests/test_sqlqueue.py::SQLite3QueueInMemory::test_protocol_1 persistqueue/tests/test_sqlqueue.py::SQLite3QueueInMemory::test_put_0 persistqueue/tests/test_sqlqueue.py::SQLite3QueueInMemory::test_raise_empty persistqueue/tests/test_sqlqueue.py::SQLite3QueueInMemory::test_random_read_write persistqueue/tests/test_sqlqueue.py::FILOSQLite3QueueTest::test_open_close_1000 persistqueue/tests/test_sqlqueue.py::FILOSQLite3QueueNoAutoCommitTest::test_open_close_1000 persistqueue/tests/test_sqlqueue.py::SQLite3UniqueQueueTest::test_add_duplicate_item persistqueue/tests/test_sqlqueue.py::SQLite3UniqueQueueTest::test_multiple_consumers persistqueue/tests/test_sqlqueue.py::SQLite3UniqueQueueTest::test_unique_dictionary_serialization_json persistqueue/tests/test_sqlqueue.py::SQLite3UniqueQueueTest::test_unique_dictionary_serialization_msgpack persistqueue/tests/test_sqlqueue.py::SQLite3UniqueQueueTest::test_unique_dictionary_serialization_pickle
persistqueue/queue.py persistqueue/sqlqueue.py persistqueue/sqlackqueue.py
persistqueue/queue.py persistqueue/sqlqueue.py persistqueue/sqlackqueue.py