AttributeError: module 'persistqueue' has no attribute 'FIFOSQLiteQueue'

I am getting AttributeError: module ‘persistqueue’ has no attribute ‘FIFOSQLiteQueue’ when I am using persistqueue module in my script. On other posts I noticed that the problem might be caused by a similar module named persistqueue.py within the same folder, but I do not have such name in my folder.

According to the documentation the attribute FIFOSQLiteQueue should exist in the module persistqueue. This is part of the code containing the attribute mentioned:

import persistqueue

(part of code)

self._persistqueue = persistqueue.FIFOSQLiteQueue(
            persistqueue_path, multithreading=True, auto_commit=False
        )

(another code)

Does anyone have similar issues and found a solution?

We’d need to see a lot more detail about what you’re attempting to have any chance of diagnosing the problem. Here are some tips for making it possible for others to see it for themselves:

Added more information within the original post.

By any chance do you have a variable called persistqueue in the (part of code)? That would cause the same problem for essentially the same underlying reason. See also:

Aside from that, does the corresponding documentation example (“Multi-thread usage for SQLite3 based queue”) work for you as advertised, by itself?

I’m well aware of that, there are variables under the name persistqueue, but I added extra characters such as persistqueue or persistqueue to differentiate it with the original module.

I haven’t tried your second option but based on the documentation itself, that feature is still available.

? I don’t see anything “added” there. Do you mean that you tried a leading or trailing underscore (_persistqueue and/or persistqueue_)? The forum markup will swallow those. But yes, that avoids the name-reuse problem.

My proposal is to make sure that the library works as advertised, starting fresh and ignoring your existing code. If it doesn’t, there’s either something wrong with the installation, or there’s a bug that needs to be reported to the developers.

If the library does work with the built-in example, then the next step is to figure out why your code is different from the example in a way that matters. It’s not possible to help any further without that. Hence the links in my first reply. Showing us “(part of code)” isn’t helpful if calling persistqueue.FIFOSQLiteQueue works without doing anything else (since, obviously, just assigning that result to self._persistqueue isn’t going to cause the problem). The problem appears to happen because of something inside the “(part of code)”, and nobody can help you with that without seeing it.

Hello, just an update, apparently name of the mentioned module has changed, thus my script produces an error. For the latest name please see: persist-queue/persistqueue/sqlqueue.py at master · peter-wangxu/persist-queue · GitHub

The correct reference should be
self._persistqueue = persistqueue.sqlqueue.FIFOSQLiteQueue( persistqueue_path, multithreading=True, auto_commit=False) per latest update.

Now my script works well.

1 Like