Comments (9)
I switched to the SQLite queue. It looks like hat got rid of he issue.
from persist-queue.
Here is the test program and queue files to reproduce the problem.
qtest.tar.gz
from persist-queue.
which version are you using?
from persist-queue.
from persist-queue.
thanks, more questions:
1: which is your os kernel and the file system(ext4? xfs? and the mount info)
2: was the queue running within a container?
3: any other environment would be helpful
from persist-queue.
Thanks for looking into this.
- The system is running mingw64 under Windows 10 Enterprise. File system: ntfs
- Not running within a container
- I have not tried to reproduce in another environment
I hope this helps!
from persist-queue.
Is there anything more on that? Having same error
from persist-queue.
It would be useful to know at what point the exceptions are raised (at queue creation / put / get) and to know what the exception will be. I was using pqueue which had the same issue, and I was able to work around it by catching pickle.UnpicklingError on pqueue.get_nowait(). In that case, I did not mind losing some data. It is certainly not ideal, but the data is lost by that point anyway. The exception otherwise requires manual intervention for the program to even continue operating with future data points. This manual intervention is not possible for my application.
from persist-queue.
I'm using the following wrapper class to avoid this problem. If anyone wishes to use this, you can. Note that the instantiation signature changes path
from a positional arg to a keyword arg.
Note that this is exceedingly dangerous code. Not only does it assume that data loss in the queue is acceptable, it also runs shutil.rmtree
without any real sanity check on what is essentially user provided input. Make sure that the path and tempdir you provide are completely disposable. Make a mistake there and you could end up accidentally wiping your entire filesystem.
import os
import shutil
class TolerantQueue(object):
def __init__(self, name=None, logger=None, **kwargs):
self._name = name or 'unspecified'
self._logger = logger
self._path = kwargs.pop('path')
self._tempdir = kwargs.pop('tempdir', None)
self._kwargs = kwargs
self._create()
def _create(self):
if not os.path.exists(self._path):
os.makedirs(self._path)
if not os.path.exists(self._tempdir):
os.makedirs(self._tempdir)
try:
self._actual_queue = Queue(path=self._path, tempdir=self._tempdir, **self._kwargs)
except pickle.UnpicklingError as e:
# info file is truncated
if self._logger:
self._logger.warn(f"Unpickling error ({e}) opening persisted queue "
f"{self._name}. Nuking. There may be data loss.")
self._reset()
def _reset(self):
self._actual_queue = None
if self._path:
shutil.rmtree(self._path, ignore_errors=True)
if self._tempdir:
shutil.rmtree(self._tempdir, ignore_errors=True)
self._create()
def get(self, *args, **kwargs):
try:
return self._actual_queue.get(*args, **kwargs)
except (EOFError, pickle.UnpicklingError) as e:
# q00000 like file is truncated or similar
if self._logger:
self._logger.warn(f"Unpickling error ({e}) reading persisted queue "
f"{self._name}. Nuking. There may be data loss.")
self._reset()
return None
def __getattr__(self, item):
return getattr(self._actual_queue, item)
from persist-queue.
Related Issues (20)
- [Regression] Can no longer retrieve None without raw=True HOT 1
- AttributeError: module 'persistqueue' has no attribute 'SQLiteAckQueue' HOT 3
- FILOSQLiteAckQueue _SQL_SELECT broken HOT 3
- qsize not changing HOT 1
- pypi release HOT 3
- mySQL db HOT 10
- SQLite objects created in a thread can only be used in that same thread HOT 2
- File is not getting cleared after get() function HOT 13
- Connection not die after kill signal. HOT 1
- sqlite vacuum not working HOT 8
- Queue items not removed after each get() HOT 3
- Priority queue HOT 4
- What if data is already serialized HOT 2
- What if data is already serialized Part II ? HOT 1
- Get() hangs when used with pqid HOT 1
- FILOSQLiteAckQueue is not exported from __init__ HOT 2
- AttributeError: module 'persistqueue' has no attribute 'MySQLQueue' HOT 3
- [BUG] "No sqlite3 module found, sqlite3 based queues are not available" during load, despite sqlite3 being present... and also works despite? HOT 3
- Error while get queue element by id
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from persist-queue.