Skip to content

[BUG] AttributeError: 'Picamera2' object has no attribute 'allocator' #1401

Closed

Description

@signag

Bug Description

On Raspberry Pi 4 and lower, I do sporadically see the following exception when taking photos or videos with raspiCamSrv:

Jul 03 12:50:18 raspi03 gunicorn[1917]: [0:40:33.356886445] [2036] ERROR Camera camera.cpp:702 Camera in Acquired state trying acquire() requiring state Available
Jul 03 12:50:18 raspi03 gunicorn[1917]: picamera2.picamera2 ERROR: Camera __init__ sequence did not complete.
Jul 03 12:50:18 raspi03 gunicorn[1917]: Exception in thread Thread-12 (listen):
Jul 03 12:50:18 raspi03 gunicorn[1917]: Traceback (most recent call last):
Jul 03 12:50:18 raspi03 gunicorn[1917]:   File "/usr/lib/python3.13/threading.py", line 1043, in _bootstrap_inner
Jul 03 12:50:18 raspi03 gunicorn[1917]:     self.run()
Jul 03 12:50:18 raspi03 gunicorn[1917]:     ~~~~~~~~^^
Jul 03 12:50:18 raspi03 gunicorn[1917]:   File "/usr/lib/python3.13/threading.py", line 994, in run
Jul 03 12:50:18 raspi03 gunicorn[1917]:     self._target(*self._args, **self._kwargs)
Jul 03 12:50:18 raspi03 gunicorn[1917]:     ~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Jul 03 12:50:18 raspi03 gunicorn[1917]:   File "/usr/lib/python3/dist-packages/picamera2/picamera2.py", line 124, in listen
Jul 03 12:50:18 raspi03 gunicorn[1917]:     callback()
Jul 03 12:50:18 raspi03 gunicorn[1917]:     ~~~~~~~~^^
Jul 03 12:50:18 raspi03 gunicorn[1917]:   File "/usr/lib/python3/dist-packages/picamera2/picamera2.py", line 141, in handle_request
Jul 03 12:50:18 raspi03 gunicorn[1917]:     self.cameras[req.cookie]._requests += [CompletedRequest(req, self.cameras[req.cookie])]
Jul 03 12:50:18 raspi03 gunicorn[1917]:                                            ~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Jul 03 12:50:18 raspi03 gunicorn[1917]:   File "/usr/lib/python3/dist-packages/picamera2/request.py", line 101, in __init__
Jul 03 12:50:18 raspi03 gunicorn[1917]:     picam2.allocator.sync(self.picam2.allocator, buffer, False) for buffer in self.request.buffers.values()
Jul 03 12:50:18 raspi03 gunicorn[1917]:     ^^^^^^^^^^^^^^^^
Jul 03 12:50:18 raspi03 gunicorn[1917]: AttributeError: 'Picamera2' object has no attribute 'allocator'

To Reproduce

I currently cannot see specific conditions under which the error occurs.

The affected functions in raspiCamSrv usually work without problems, but sometimes the error occurs.

I also have some doubt in Camera in Acquired state trying acquire() requiring state Available because the relevant Picamera2 calls are done after the camera has been closed previously and a garbage collection has been executed.

On Raspberry Pi 5, this error has never been observed.

Hardware and Software Stack

Image

Activity

  1. davidplowman commented on Jul 3, 2026

    @davidplowman
    Collaborator

    I notice that the following:

    import time
    from picamera2 import Picamera2
    picam2 = Picamera2()
    picam2.start()
    time.sleep(1)
    Picamera2()
    

    fails with exactly this error. So I suppose someone is re-opening the camera by creating a new Picamera2(), while that device is already open and running. Obviously that's going to fail, but it shouldn't be trashing your previously opened instance. #1402 should fix this.

  2. signag commented on Jul 6, 2026

    @signag
    Author

    Hi,

    thanks for your quick response.
    Based on your info, I could locate and fix my bug.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions