Video capture breaks during processing

Hello!

I have some problems with live video-processing using Python and gstreamer on Jetson Nano.

I have my dummy.service, which activates Python script on boot:

[Unit]
Description=Dummy Service
After=multi-user.target
Conflicts=getty@tty1.service

[Service]
Type=simple
RestartSec=20
WatchdogSec=600
Restart=on-failure
User=user1
ExecStart=/usr/bin/python3 /home/user1/doorbell_bot/video2.py
StandardInput=tty-force

[Install]
WantedBy=multi-user.target

Python script creates video capture in this way:

src="nvarguscamerasrc ! video/x-raw(memory:NVMM), width=(int)1920, height=(int)1080,format=(string)NV12, framerate=(fraction)30/1 ! nvvidconv ! video/x-raw, format=(string)BGRx ! videoconvert ! video/x-raw, format=(string)BGR ! appsink"
capture = cv2.VideoCapture(src, cv2.CAP_GSTREAMER)  

And then this video capture is being processed in infinite loop using cv2, dlib and other face recognition libraries.

The problem is that I suddenly noticed, that from time to time my script is just dies no produce no result. I tried to explore my log, but it was nothing helpful there - the processing just suddenly stops with no mistake.

I added a try-catch in while loop, and I caught an error that video capture returns None. I realized that something is not OK with camera. I tried to restart nvargus-daemon and it helped.

It is a piece of /var/log/syslog:

Jun  7 22:57:18 user1-desktop systemd-timesyncd[3554]: Synchronized to time server 195.112.113.253:123 (1.pool.ntp.org).
Jun  7 22:57:37 user1-desktop CRON[3937]: (CRON) info (No MTA installed, discarding output)
Jun  7 22:57:37 user1-desktop nvargus-daemon[5033]: === python3[6655]: Connection established (7F2744E1D0)=== python3[6655]: CameraProvider initialized (0x7f70b0b020)(Argus) Error AlreadyAllocated: Device 0 (of 1) is in use (in src/api/CameraProviderImpl.cpp, function createCaptureSession(), line 236)
Jun  7 22:59:57 user1-desktop systemd[1]: Started Session 6 of user user1.
Jun  7 23:00:10 user1-desktop systemd[1]: Stopping Dummy Service...
Jun  7 23:00:10 user1-desktop nvargus-daemon[5033]: === python3[5538]: Connection closed (7F749531D0)=== python3[5538]: WARNING: CameraProvider was not destroyed before client connection terminated.=== python3[5538]:          The client may have abnormally terminated. Destroying CameraProvider...=== python3[5538]: CameraProvider destroyed (0x7f708fd0a0)=== python3[5538]: WARNING: Cleaning up 1 outstanding requests...=== python3[5538]: WARNING: Cleaning up 1 outstanding streams...SCF: Error InvalidState: 3 buffers still pending during EGLStreamProducer destruction (propagating from src/services/gl/EGLStreamProducer.cpp, function freeBuffers(), line 306)
Jun  7 23:00:10 user1-desktop nvargus-daemon[5033]: SCF: Error InvalidState:  (propagating from src/services/gl/EGLStreamProducer.cpp, function ~EGLStreamProducer(), line 50)
Jun  7 23:00:10 user1-desktop nvargus-daemon[5033]: === python3[5538]: WARNING: Cleaning up 1 outstanding stream settings...=== python3[5538]: WARNING: Cleaning up 1 outstanding sessions...(NvCameraUtils) Error InvalidState: Mutex not initialized (/dvs/git/dirty/git-master_linux/camera/core_scf/src/services/gl/EGLStreamProducer.cpp:400) (in Mutex.cpp, function lock(), line 79)
Jun  7 23:00:10 user1-desktop nvargus-daemon[5033]: (NvCameraUtils) Error InvalidState: Mutex not initialized (/dvs/git/dirty/git-master_linux/camera/core_scf/src/services/gl/EGLStreamProducer.cpp:212) (in Mutex.cpp, function lock(), line 79)
Jun  7 23:00:10 user1-desktop nvargus-daemon[5033]: SCF: Error BadParameter:  (propagating from src/services/gl/EGLStreamProducer.cpp, function allocateAndRegisterBuffers(), line 265)
Jun  7 23:00:10 user1-desktop nvargus-daemon[5033]: (NvCameraUtils) Error InvalidState: Mutex has not been initialized (in Mutex.cpp, function unlock(), line 88)
Jun  7 23:00:10 user1-desktop nvargus-daemon[5033]: SCF: Error BadParameter:  (propagating from src/services/gl/EGLStreamProducer.cpp, function getBuffer(), line 415)
Jun  7 23:00:10 user1-desktop nvargus-daemon[5033]: (NvCameraUtils) Error InvalidState: Mutex has not been initialized (in Mutex.cpp, function unlock(), line 88)
Jun  7 23:00:10 user1-desktop nvargus-daemon[5033]: SCF: Error BadParameter:  (propagating from src/services/gl/EGLStreamProducer.cpp, function returnFrame(), line 372)
Jun  7 23:00:10 user1-desktop nvargus-daemon[5033]: SCF: Error BadParameter:  (propagating from src/services/gl/EGLStreamProducer.cpp, function getBuffer(), line 434)
Jun  7 23:00:10 user1-desktop nvargus-daemon[5033]: SCF: Error BadParameter:  (propagating from src/components/CaptureContainerImpl.cpp, function assignAllBuffersFromStream(), line 230)
Jun  7 23:00:10 user1-desktop nvargus-daemon[5033]: SCF: Error BadParameter:  (propagating from src/components/stages/CCDataSetupStage.cpp, function doHandleRequest(), line 68)
Jun  7 23:00:10 user1-desktop nvargus-daemon[5033]: SCF: Error BadParameter:  (propagating from src/components/stages/OrderedStage.cpp, function doExecute(), line 158)
Jun  7 23:00:10 user1-desktop nvargus-daemon[5033]: SCF: Error BadParameter: Sending critical error event (in src/api/Session.cpp, function sendErrorEvent(), line 990)
Jun  7 23:00:10 user1-desktop systemd[1]: Stopped Dummy Service.
Jun  7 23:00:10 user1-desktop nvargus-daemon[5033]: (NvCameraUtils) Error InvalidState: Mutex not initialized (/dvs/git/dirty/git-master_linux/camera/core_scf/src/services/gl/EGLStreamProducer.cpp:498) (in Mutex.cpp, function lock(), line 79)
Jun  7 23:00:10 user1-desktop nvargus-daemon[5033]: SCF: Error BadParameter: Buffer is not pending (in src/services/gl/EGLStreamProducer.cpp, function presentBufferInternal(), line 502)
Jun  7 23:00:10 user1-desktop nvargus-daemon[5033]: (NvCameraUtils) Error InvalidState: Mutex has not been initialized (in Mutex.cpp, function unlock(), line 88)
Jun  7 23:00:10 user1-desktop nvargus-daemon[5033]: SCF: Error BadParameter:  (propagating from src/services/gl/EGLStreamProducer.cpp, function presentBuffer(), line 487)
Jun  7 23:00:10 user1-desktop nvargus-daemon[5033]: SCF: Error BadParameter:  (propagating from src/components/CaptureContainerImpl.cpp, function returnBuffer(), line 447)
Jun  7 23:00:10 user1-desktop nvargus-daemon[5033]: SCF: Error BadParameter:  (propagating from src/components/stages/BufferReturnStage.h, function doExecute(), line 43)
Jun  7 23:00:10 user1-desktop nvargus-daemon[5033]: (NvCameraUtils) Error InvalidState: Mutex not initialized (/dvs/git/dirty/git-master_linux/camera/core_scf/src/services/gl/EGLStreamProducer.cpp:498) (in Mutex.cpp, function lock(), line 79)
Jun  7 23:00:10 user1-desktop nvargus-daemon[5033]: (NvCameraUtils) Error InvalidState: Mutex has not been initialized (in Mutex.cpp, function unlock(), line 88)
Jun  7 23:00:10 user1-desktop nvargus-daemon[5033]: (NvCameraUtils) Error InvalidState: Mutex not initialized (/dvs/git/dirty/git-master_linux/camera/core_scf/src/services/gl/EGLStreamProducer.cpp:534) (in Mutex.cpp, function lock(), line 79)
Jun  7 23:00:10 user1-desktop nvargus-daemon[5033]: SCF: Error BadParameter:  (propagating from src/services/gl/EGLStreamProducer.cpp, function presentBufferInternal(), line 539)
Jun  7 23:00:10 user1-desktop nvargus-daemon[5033]: (NvCameraUtils) Error InvalidState: Mutex has not been initialized (in Mutex.cpp, function unlock(), line 88)
Jun  7 23:00:10 user1-desktop nvargus-daemon[5033]: (NvCameraUtils) Error InvalidState: Mutex not initialized (/dvs/git/dirty/git-master_linux/camera/core_scf/src/services/gl/EGLStreamProducer.cpp:552) (in Mutex.cpp, function lock(), line 79)
Jun  7 23:00:10 user1-desktop nvargus-daemon[5033]: (NvCameraUtils) Error InvalidState: Mutex has not been initialized (in Mutex.cpp, function unlock(), line 88)
Jun  7 23:00:10 user1-desktop nvargus-daemon[5033]: (NvCameraUtils) Error InvalidState: Mutex not initialized (/dvs/git/dirty/git-master_linux/camera/core_scf/src/services/gl/EGLStreamProducer.cpp:498) (in Mutex.cpp, function lock(), line 79)
Jun  7 23:00:10 user1-desktop nvargus-daemon[5033]: (NvCameraUtils) Error InvalidState: Mutex has not been initialized (in Mutex.cpp, function unlock(), line 88)
Jun  7 23:00:10 user1-desktop nvargus-daemon[5033]: (NvCameraUtils) Error InvalidState: Mutex not initialized (/dvs/git/dirty/git-master_linux/camera/core_scf/src/services/gl/EGLStreamProducer.cpp:534) (in Mutex.cpp, function lock(), line 79)
Jun  7 23:00:10 user1-desktop nvargus-daemon[5033]: SCF: Error BadParameter:  (propagating from src/services/gl/EGLStreamProducer.cpp, function presentBufferInternal(), line 539)
Jun  7 23:00:10 user1-desktop nvargus-daemon[5033]: (NvCameraUtils) Error InvalidState: Mutex has not been initialized (in Mutex.cpp, function unlock(), line 88)
Jun  7 23:00:10 user1-desktop nvargus-daemon[5033]: (NvCameraUtils) Error InvalidState: Mutex not initialized (/dvs/git/dirty/git-master_linux/camera/core_scf/src/services/gl/EGLStreamProducer.cpp:552) (in Mutex.cpp, function lock(), line 79)
Jun  7 23:00:10 user1-desktop nvargus-daemon[5033]: (NvCameraUtils) Error InvalidState: Mutex has not been initialized (in Mutex.cpp, function unlock(), line 88)
Jun  7 23:00:15 user1-desktop nvargus-daemon[5033]: waitForIdleLocked remaining request 5367
Jun  7 23:00:15 user1-desktop nvargus-daemon[5033]: waitForIdleLocked remaining request 5366
Jun  7 23:00:15 user1-desktop nvargus-daemon[5033]: SCF: Error Timeout: waitForIdle() timed out (in src/api/Session.cpp, function waitForIdleLocked(), line 920)
Jun  7 23:00:15 user1-desktop nvargus-daemon[5033]: (Argus) Error Timeout:  (propagating from src/api/CaptureSessionImpl.cpp, function destroy(), line 166)
Jun  7 23:00:20 user1-desktop nvargus-daemon[5033]: waitForIdleLocked remaining request 5367
Jun  7 23:00:20 user1-desktop nvargus-daemon[5033]: waitForIdleLocked remaining request 5366
Jun  7 23:00:20 user1-desktop nvargus-daemon[5033]: SCF: Error Timeout: waitForIdle() timed out (in src/api/Session.cpp, function waitForIdleLocked(), line 920)
Jun  7 23:00:20 user1-desktop nvargus-daemon[5033]: SCF: Error Timeout:  (propagating from src/api/Session.cpp, function abortCaptures(), line 886)
Jun  7 23:00:20 user1-desktop nvargus-daemon[5033]: SCF: Error Timeout:  (propagating from src/api/Session.cpp, function shutdown(), line 400)
Jun  7 23:00:20 user1-desktop nvargus-daemon[5033]: PowerServiceCore:handleRequests: timePassed = 5034
Jun  7 23:00:20 user1-desktop nvargus-daemon[5033]: SCF: Error Timeout:  (propagating from src/api/Session.cpp, function shutdown(), line 500)
Jun  7 23:00:20 user1-desktop nvargus-daemon[5033]: SCF: Error Timeout:  (propagating from src/api/CameraDriver.cpp, function deleteSession(), line 619)
Jun  7 23:00:20 user1-desktop nvargus-daemon[5033]: (Argus) Error Timeout:  (propagating from src/api/CaptureSessionImpl.cpp, function destroy(), line 191)
Jun  7 23:00:20 user1-desktop nvargus-daemon[5033]: === python3[5538]: NOTE: Destroy all libargus objects before destroying the CameraProvider to avoid these warnings.=== python3[5538]: Connection cleaned up (7F749531D0)free(): invalid size
Jun  7 23:01:48 user1-desktop anacron[3738]: Job `cron.daily' started
Jun  7 23:01:48 user1-desktop anacron[6858]: Updated timestamp for job `cron.daily' to 2021-06-07
Jun  7 23:01:48 user1-desktop cracklib: no dictionary update necessary.
Jun  7 23:01:51 user1-desktop systemd[1]: nvargus-daemon.service: Main process exited, code=killed, status=6/ABRT
Jun  7 23:01:51 user1-desktop systemd[1]: nvargus-daemon.service: Failed with result 'signal'.
Jun  7 23:01:52 user1-desktop systemd[1]: nvargus-daemon.service: Service hold-off time over, scheduling restart.
Jun  7 23:01:52 user1-desktop systemd[1]: nvargus-daemon.service: Scheduled restart job, restart counter is at 1.
Jun  7 23:01:52 user1-desktop systemd[1]: Stopped Argus daemon.
Jun  7 23:01:52 user1-desktop systemd[1]: Started Argus daemon.
Jun  7 23:01:52 user1-desktop anacron[3738]: Job `cron.daily' terminated
Jun  7 23:01:56 user1-desktop gnome-shell[5610]: pushModal: invocation of begin_modal failed
Jun  7 23:01:56 user1-desktop gnome-shell[5610]: pushModal: invocation of begin_modal failed
Jun  7 23:01:56 user1-desktop gnome-shell[5610]: error: Unable to lock: Lock was blocked by an application
Jun  7 23:02:19 user1-desktop NetworkManager[4102]: <info>  [1623096139.6792] connectivity: (wlan0) timed out
Jun  7 23:02:19 user1-desktop NetworkManager[4102]: <info>  [1623096139.6794] manager: NetworkManager state is now CONNECTED_SITE
Jun  7 23:02:19 user1-desktop whoopsie[4621]: [23:02:19] offline
Jun  7 23:02:19 user1-desktop systemd[1]: Starting Network Manager Script Dispatcher Service...
Jun  7 23:02:19 user1-desktop dbus-daemon[3854]: [system] Activating via systemd: service name='org.freedesktop.nm_dispatcher' unit='dbus-org.freedesktop.nm-dispatcher.service' requested by ':1.9' (uid=0 pid=4102 comm="/usr/sbin/NetworkManager --no-daemon ")
Jun  7 23:02:19 user1-desktop dbus-daemon[3854]: [system] Successfully activated service 'org.freedesktop.nm_dispatcher'
Jun  7 23:02:19 user1-desktop systemd[1]: Started Network Manager Script Dispatcher Service.
Jun  7 23:02:19 user1-desktop nm-dispatcher: req:1 'connectivity-change': new request (1 scripts)
Jun  7 23:02:19 user1-desktop nm-dispatcher: req:1 'connectivity-change': start running ordered scripts...
Jun  7 23:03:14 user1-desktop systemd[1]: Started Session 7 of user user1.
Jun  7 23:04:22 user1-desktop anacron[3738]: Job `cron.weekly' started
Jun  7 23:04:22 user1-desktop anacron[7155]: Updated timestamp for job `cron.weekly' to 2021-06-07
Jun  7 23:04:22 user1-desktop anacron[3738]: Job `cron.weekly' terminated
Jun  7 23:04:22 user1-desktop anacron[3738]: Normal exit (2 jobs run)
Jun  7 23:06:37 user1-desktop systemd[1]: Started Session 8 of user user1.
Jun  7 23:06:45 user1-desktop systemd[1]: Started Dummy Service.
Jun  7 23:06:50 user1-desktop NetworkManager[4102]: <info>  [1623096410.9960] manager: NetworkManager state is now CONNECTED_GLOBAL
Jun  7 23:06:51 user1-desktop dbus-daemon[3854]: [system] Activating via systemd: service name='org.freedesktop.nm_dispatcher' unit='dbus-org.freedesktop.nm-dispatcher.service' requested by ':1.9' (uid=0 pid=4102 comm="/usr/sbin/NetworkManager --no-daemon ")
Jun  7 23:06:51 user1-desktop systemd[1]: Starting Network Manager Script Dispatcher Service...
Jun  7 23:06:51 user1-desktop whoopsie[4621]: [23:06:51] The default IPv4 route is: /org/freedesktop/NetworkManager/ActiveConnection/1
Jun  7 23:06:51 user1-desktop whoopsie[4621]: [23:06:51] Not a paid data plan: /org/freedesktop/NetworkManager/ActiveConnection/1
Jun  7 23:06:51 user1-desktop whoopsie[4621]: [23:06:51] Found usable connection: /org/freedesktop/NetworkManager/ActiveConnection/1
Jun  7 23:06:51 user1-desktop dbus-daemon[3854]: [system] Successfully activated service 'org.freedesktop.nm_dispatcher'
Jun  7 23:06:51 user1-desktop systemd[1]: Started Network Manager Script Dispatcher Service.
Jun  7 23:06:51 user1-desktop nm-dispatcher: req:1 'connectivity-change': new request (1 scripts)
Jun  7 23:06:51 user1-desktop nm-dispatcher: req:1 'connectivity-change': start running ordered scripts...
Jun  7 23:06:52 user1-desktop whoopsie[4621]: [23:06:52] online
Jun  7 23:09:18 user1-desktop systemd[1]: Stopping Dummy Service...
Jun  7 23:09:18 user1-desktop systemd[1]: Stopped Dummy Service.
Jun  7 23:09:34 user1-desktop systemd[1]: Started Dummy Service.
Jun  7 23:09:43 user1-desktop nvargus-daemon[6962]: === NVIDIA Libargus Camera Service (0.97.3)=== Listening for connections...=== python3[7437]: Connection established (7F7B0551D0)OFParserListModules: module list: /proc/device-tree/tegra-camera-platform/modules/module0
Jun  7 23:09:43 user1-desktop nvargus-daemon[6962]: OFParserGetVirtualDevice: NVIDIA Camera virtual enumerator not found in proc device-tree
Jun  7 23:09:44 user1-desktop nvargus-daemon[6962]: ---- imager: No override file found. ----
Jun  7 23:09:44 user1-desktop nvargus-daemon[6962]: LSC: LSC surface is not based on full res!
Jun  7 23:09:44 user1-desktop nvargus-daemon[6962]: === python3[7437]: CameraProvider initialized (0x7f74924ce0)LSC: LSC surface is not based on full res!
Jun  7 23:11:49 user1-desktop systemd[1]: Starting Cleanup of Temporary Directories...
Jun  7 23:11:49 user1-desktop systemd[1]: Started Cleanup of Temporary Directories.
Jun  7 23:12:19 user1-desktop NetworkManager[4102]: <info>  [1623096739.6808] connectivity: (wlan0) timed out
Jun  7 23:12:19 user1-desktop NetworkManager[4102]: <info>  [1623096739.6809] manager: NetworkManager state is now CONNECTED_SITE
Jun  7 23:12:19 user1-desktop dbus-daemon[3854]: [system] Activating via systemd: service name='org.freedesktop.nm_dispatcher' unit='dbus-org.freedesktop.nm-dispatcher.service' requested by ':1.9' (uid=0 pid=4102 comm="/usr/sbin/NetworkManager --no-daemon ")
Jun  7 23:12:19 user1-desktop whoopsie[4621]: [23:12:19] offline
Jun  7 23:12:19 user1-desktop systemd[1]: Starting Network Manager Script Dispatcher Service...
Jun  7 23:12:19 user1-desktop dbus-daemon[3854]: [system] Successfully activated service 'org.freedesktop.nm_dispatcher'
Jun  7 23:12:19 user1-desktop systemd[1]: Started Network Manager Script Dispatcher Service.
Jun  7 23:12:19 user1-desktop nm-dispatcher: req:1 'connectivity-change': new request (1 scripts)
Jun  7 23:12:19 user1-desktop nm-dispatcher: req:1 'connectivity-change': start running ordered scripts...
Jun  7 23:16:50 user1-desktop NetworkManager[4102]: <info>  [1623097010.9880] manager: NetworkManager state is now CONNECTED_GLOBAL
Jun  7 23:16:51 user1-desktop dbus-daemon[3854]: [system] Activating via systemd: service name='org.freedesktop.nm_dispatcher' unit='dbus-org.freedesktop.nm-dispatcher.service' requested by ':1.9' (uid=0 pid=4102 comm="/usr/sbin/NetworkManager --no-daemon ")
Jun  7 23:16:51 user1-desktop systemd[1]: Starting Network Manager Script Dispatcher Service...
Jun  7 23:16:51 user1-desktop whoopsie[4621]: [23:16:51] The default IPv4 route is: /org/freedesktop/NetworkManager/ActiveConnection/1
Jun  7 23:16:51 user1-desktop whoopsie[4621]: [23:16:51] Not a paid data plan: /org/freedesktop/NetworkManager/ActiveConnection/1
Jun  7 23:16:51 user1-desktop whoopsie[4621]: [23:16:51] Found usable connection: /org/freedesktop/NetworkManager/ActiveConnection/1
Jun  7 23:16:51 user1-desktop whoopsie[4621]: [23:16:51] online
Jun  7 23:16:51 user1-desktop dbus-daemon[3854]: [system] Successfully activated service 'org.freedesktop.nm_dispatcher'
Jun  7 23:16:51 user1-desktop systemd[1]: Started Network Manager Script Dispatcher Service.
Jun  7 23:16:51 user1-desktop nm-dispatcher: req:1 'connectivity-change': new request (1 scripts)
Jun  7 23:16:51 user1-desktop nm-dispatcher: req:1 'connectivity-change': start running ordered scripts...
Jun  7 23:17:01 user1-desktop CRON[7815]: (root) CMD (   cd / && run-parts --report /etc/cron.hourly)
Jun  7 23:17:30 user1-desktop systemd[1]: Starting Daily apt download activities...
Jun  7 23:17:34 user1-desktop systemd[1]: Started Daily apt download activities.
Jun  7 23:19:34 user1-desktop systemd[1]: dummy.service: Watchdog timeout (limit 10min)!
Jun  7 23:19:34 user1-desktop systemd[1]: dummy.service: Killing process 7437 (python3) with signal SIGABRT.
Jun  7 23:19:35 user1-desktop nvargus-daemon[6962]: SCF: Error InvalidState:  (propagating from src/services/gl/EGLStreamProducer.cpp, function returnFrame(), line 372)
Jun  7 23:19:35 user1-desktop nvargus-daemon[6962]: SCF: Error InvalidState:  (propagating from src/services/gl/EGLStreamProducer.cpp, function getBuffer(), line 434)
Jun  7 23:19:35 user1-desktop nvargus-daemon[6962]: SCF: Error InvalidState:  (propagating from src/components/CaptureContainerImpl.cpp, function assignAllBuffersFromStream(), line 230)
Jun  7 23:19:35 user1-desktop nvargus-daemon[6962]: SCF: Error InvalidState:  (propagating from src/components/stages/CCDataSetupStage.cpp, function doHandleRequest(), line 68)
Jun  7 23:19:35 user1-desktop nvargus-daemon[6962]: SCF: Error InvalidState:  (propagating from src/components/stages/OrderedStage.cpp, function doExecute(), line 158)
Jun  7 23:19:35 user1-desktop nvargus-daemon[6962]: SCF: Error InvalidState: Sending critical error event (in src/api/Session.cpp, function sendErrorEvent(), line 990)
Jun  7 23:19:35 user1-desktop nvargus-daemon[6962]: SCF: Error InvalidState:  (propagating from src/services/gl/EGLStreamProducer.cpp, function returnFrame(), line 372)
Jun  7 23:19:35 user1-desktop nvargus-daemon[6962]: SCF: Error InvalidState:  (propagating from src/services/gl/EGLStreamProducer.cpp, function getBuffer(), line 434)
Jun  7 23:19:35 user1-desktop nvargus-daemon[6962]: SCF: Error InvalidState:  (propagating from src/components/CaptureContainerImpl.cpp, function assignAllBuffersFromStream(), line 230)
Jun  7 23:19:35 user1-desktop nvargus-daemon[6962]: SCF: Error InvalidState:  (propagating from src/components/stages/CCDataSetupStage.cpp, function doHandleRequest(), line 68)
Jun  7 23:19:35 user1-desktop nvargus-daemon[6962]: SCF: Error InvalidState:  (propagating from src/components/stages/OrderedStage.cpp, function doExecute(), line 158)
Jun  7 23:19:35 user1-desktop systemd[1]: dummy.service: Main process exited, code=dumped, status=6/ABRT
Jun  7 23:19:35 user1-desktop systemd[1]: dummy.service: Failed with result 'watchdog'.
Jun  7 23:19:35 user1-desktop nvargus-daemon[6962]: === python3[7437]: Connection closed (7F7B0551D0)=== python3[7437]: WARNING: CameraProvider was not destroyed before client connection terminated.=== python3[7437]:          The client may have abnormally terminated. Destroying CameraProvider...=== python3[7437]: CameraProvider destroyed (0x7f74924ce0)=== python3[7437]: WARNING: Cleaning up 1 outstanding requests...=== python3[7437]: WARNING: Cleaning up 1 outstanding streams...=== python3[7437]: WARNING: Cleaning up 1 outstanding stream settings...=== python3[7437]: WARNING: Cleaning up 1 outstanding sessions...
Jun  7 23:19:35 user1-desktop systemd[1]: nvargus-daemon.service: Main process exited, code=killed, status=11/SEGV
Jun  7 23:19:35 user1-desktop systemd[1]: nvargus-daemon.service: Failed with result 'signal'.
Jun  7 23:19:36 user1-desktop systemd[1]: nvargus-daemon.service: Service hold-off time over, scheduling restart.
Jun  7 23:19:36 user1-desktop systemd[1]: nvargus-daemon.service: Scheduled restart job, restart counter is at 2.
Jun  7 23:19:36 user1-desktop systemd[1]: Stopped Argus daemon.
Jun  7 23:19:36 user1-desktop systemd[1]: Started Argus daemon.
Jun  7 23:19:55 user1-desktop systemd[1]: dummy.service: Service hold-off time over, scheduling restart.
Jun  7 23:19:55 user1-desktop systemd[1]: dummy.service: Scheduled restart job, restart counter is at 1.
Jun  7 23:19:55 user1-desktop systemd[1]: Stopped Dummy Service.
Jun  7 23:19:55 user1-desktop systemd[1]: Started Dummy Service.
Jun  7 23:20:04 user1-desktop nvargus-daemon[7956]: === NVIDIA Libargus Camera Service (0.97.3)=== Listening for connections...=== python3[7989]: Connection established (7F7F6211D0)OFParserListModules: module list: /proc/device-tree/tegra-camera-platform/modules/module0
Jun  7 23:20:05 user1-desktop nvargus-daemon[7956]: OFParserGetVirtualDevice: NVIDIA Camera virtual enumerator not found in proc device-tree
Jun  7 23:20:05 user1-desktop nvargus-daemon[7956]: ---- imager: No override file found. ----
Jun  7 23:20:05 user1-desktop nvargus-daemon[7956]: LSC: LSC surface is not based on full res!
Jun  7 23:20:05 user1-desktop nvargus-daemon[7956]: === python3[7989]: CameraProvider initialized (0x7f788fd170)LSC: LSC surface is not based on full res!

I rebooted my Jetson Nano in one moment, so it migth be represented in logs. I see many error messages here, but I don’t really know what to do. I would realy appreciate your help :)

Hi,
There are errors from nvargus-daemon. Seems to be instability of the camera source. Does it happen only when you execute python script at booting? Please also check if you can run this:
OpenCV Video Capture with GStreamer doesn't work on ROS-melodic - #3 by DaneLLL

And please share your release version( $ head -1 /etc/nv_tegra_release )

Not sure for your case, but also note that Argus has a driver side managed by nvargus-deamon and a socket /tmp/argus_socket for communicating with userspace applications such as nvarguscamerasrc.
Be sure the socket exists (see this post for rc.local script). Or add dependency to nvargus-daemon.service so that your script will only be launched later.

Thank you for quick answer!

I am connected via ssh, but if I change code in video2.py and restart dummy.service, I get the following logs:

Jun  9 23:06:25 user1-desktop NetworkManager[3985]: <info>  [1623269185.4764] manager: NetworkManager state is now CONNECTED_GLOBAL
Jun  9 23:06:25 user1-desktop dbus-daemon[3826]: [system] Activating via systemd: service name='org.freedesktop.nm_dispatcher' unit='dbus-org.freedesktop.nm-dispatcher.service' requested by ':1.9' (uid=0 pid=3985 comm="/usr/sbin/NetworkManager --no-daemon ")
Jun  9 23:06:25 user1-desktop systemd[1]: Starting Network Manager Script Dispatcher Service...
Jun  9 23:06:25 user1-desktop whoopsie[4469]: [23:06:25] The default IPv4 route is: /org/freedesktop/NetworkManager/ActiveConnection/1
Jun  9 23:06:25 user1-desktop whoopsie[4469]: [23:06:25] Not a paid data plan: /org/freedesktop/NetworkManager/ActiveConnection/1
Jun  9 23:06:25 user1-desktop whoopsie[4469]: [23:06:25] Found usable connection: /org/freedesktop/NetworkManager/ActiveConnection/1
Jun  9 23:06:25 user1-desktop whoopsie[4469]: [23:06:25] online
Jun  9 23:06:25 user1-desktop dbus-daemon[3826]: [system] Successfully activated service 'org.freedesktop.nm_dispatcher'
Jun  9 23:06:25 user1-desktop systemd[1]: Started Network Manager Script Dispatcher Service.
Jun  9 23:06:25 user1-desktop nm-dispatcher: req:1 'connectivity-change': new request (1 scripts)
Jun  9 23:06:25 user1-desktop nm-dispatcher: req:1 'connectivity-change': start running ordered scripts...
Jun  9 23:06:41 user1-desktop systemd[1]: Stopping Dummy Service...
Jun  9 23:06:41 user1-desktop nvargus-daemon[9273]: === python3[9313]: Connection closed (7F828211D0)=== python3[9313]: WARNING: CameraProvider was not destroyed before client connection terminated.=== python3[9313]:          The client may have abnormally terminated. Destroying CameraProvider...=== python3[9313]: CameraProvider destroyed (0x7f7c922240)=== python3[9313]: WARNING: Cleaning up 1 outstanding requests...=== python3[9313]: WARNING: Cleaning up 1 outstanding streams...SCF: Error InvalidState: 4 buffers still pending during EGLStreamProducer destruction (propagating from src/services/gl/EGLStreamProducer.cpp, function freeBuffers(), line 306)
Jun  9 23:06:41 user1-desktop nvargus-daemon[9273]: SCF: Error InvalidState:  (propagating from src/services/gl/EGLStreamProducer.cpp, function ~EGLStreamProducer(), line 50)
Jun  9 23:06:41 user1-desktop systemd[1]: Stopped Dummy Service.
Jun  9 23:06:41 user1-desktop nvargus-daemon[9273]: === python3[9313]: WARNING: Cleaning up 1 outstanding stream settings...=== python3[9313]: WARNING: Cleaning up 1 outstanding sessions...(NvCameraUtils) Error InvalidState: Mutex not initialized (/dvs/git/dirty/git-master_linux/camera/core_scf/src/services/gl/EGLStreamProducer.cpp:498) (in Mutex.cpp, function lock(), line 79)
Jun  9 23:06:41 user1-desktop nvargus-daemon[9273]: SCF: Error BadParameter: Buffer is not pending (in src/services/gl/EGLStreamProducer.cpp, function presentBufferInternal(), line 502)
Jun  9 23:06:41 user1-desktop systemd[1]: Started Dummy Service.
Jun  9 23:06:41 user1-desktop nvargus-daemon[9273]: (NvCameraUtils) Error InvalidState: Mutex has not been initialized (in Mutex.cpp, function unlock(), line 88)
Jun  9 23:06:41 user1-desktop nvargus-daemon[9273]: SCF: Error BadParameter:  (propagating from src/services/gl/EGLStreamProducer.cpp, function presentBuffer(), line 487)
Jun  9 23:06:41 user1-desktop nvargus-daemon[9273]: SCF: Error BadParameter:  (propagating from src/components/CaptureContainerImpl.cpp, function returnBuffer(), line 447)
Jun  9 23:06:41 user1-desktop nvargus-daemon[9273]: SCF: Error BadParameter:  (propagating from src/components/stages/BufferReturnStage.h, function doExecute(), line 43)
Jun  9 23:06:41 user1-desktop nvargus-daemon[9273]: SCF: Error BadParameter: Sending critical error event (in src/api/Session.cpp, function sendErrorEvent(), line 990)
Jun  9 23:06:41 user1-desktop nvargus-daemon[9273]: (NvCameraUtils) Error InvalidState: Mutex not initialized (/dvs/git/dirty/git-master_linux/camera/core_scf/src/services/gl/EGLStreamProducer.cpp:400) (in Mutex.cpp, function lock(), line 79)
Jun  9 23:06:41 user1-desktop nvargus-daemon[9273]: (NvCameraUtils) Error InvalidState: Mutex not initialized (/dvs/git/dirty/git-master_linux/camera/core_scf/src/services/gl/EGLStreamProducer.cpp:212) (in Mutex.cpp, function lock(), line 79)
Jun  9 23:06:41 user1-desktop nvargus-daemon[9273]: SCF: Error BadParameter:  (propagating from src/services/gl/EGLStreamProducer.cpp, function allocateAndRegisterBuffers(), line 265)
Jun  9 23:06:41 user1-desktop nvargus-daemon[9273]: (NvCameraUtils) Error InvalidState: Mutex has not been initialized (in Mutex.cpp, function unlock(), line 88)
Jun  9 23:06:41 user1-desktop nvargus-daemon[9273]: SCF: Error BadParameter:  (propagating from src/services/gl/EGLStreamProducer.cpp, function getBuffer(), line 415)
Jun  9 23:06:41 user1-desktop nvargus-daemon[9273]: (NvCameraUtils) Error InvalidState: Mutex has not been initialized (in Mutex.cpp, function unlock(), line 88)
Jun  9 23:06:41 user1-desktop nvargus-daemon[9273]: SCF: Error BadParameter:  (propagating from src/services/gl/EGLStreamProducer.cpp, function returnFrame(), line 372)
Jun  9 23:06:41 user1-desktop nvargus-daemon[9273]: SCF: Error BadParameter:  (propagating from src/services/gl/EGLStreamProducer.cpp, function getBuffer(), line 434)
Jun  9 23:06:41 user1-desktop nvargus-daemon[9273]: SCF: Error BadParameter:  (propagating from src/components/CaptureContainerImpl.cpp, function assignAllBuffersFromStream(), line 230)
Jun  9 23:06:41 user1-desktop nvargus-daemon[9273]: SCF: Error BadParameter:  (propagating from src/components/stages/CCDataSetupStage.cpp, function doHandleRequest(), line 68)
Jun  9 23:06:41 user1-desktop nvargus-daemon[9273]: SCF: Error BadParameter:  (propagating from src/components/stages/OrderedStage.cpp, function doExecute(), line 158)
Jun  9 23:06:41 user1-desktop nvargus-daemon[9273]: (NvCameraUtils) Error InvalidState: Mutex not initialized (/dvs/git/dirty/git-master_linux/camera/core_scf/src/services/gl/EGLStreamProducer.cpp:498) (in Mutex.cpp, function lock(), line 79)
Jun  9 23:06:41 user1-desktop nvargus-daemon[9273]: (NvCameraUtils) Error InvalidState: Mutex has not been initialized (in Mutex.cpp, function unlock(), line 88)
Jun  9 23:06:41 user1-desktop nvargus-daemon[9273]: (NvCameraUtils) Error InvalidState: Mutex not initialized (/dvs/git/dirty/git-master_linux/camera/core_scf/src/services/gl/EGLStreamProducer.cpp:534) (in Mutex.cpp, function lock(), line 79)
Jun  9 23:06:41 user1-desktop nvargus-daemon[9273]: SCF: Error BadParameter:  (propagating from src/services/gl/EGLStreamProducer.cpp, function presentBufferInternal(), line 539)
Jun  9 23:06:41 user1-desktop nvargus-daemon[9273]: (NvCameraUtils) Error InvalidState: Mutex has not been initialized (in Mutex.cpp, function unlock(), line 88)
Jun  9 23:06:41 user1-desktop nvargus-daemon[9273]: (NvCameraUtils) Error InvalidState: Mutex not initialized (/dvs/git/dirty/git-master_linux/camera/core_scf/src/services/gl/EGLStreamProducer.cpp:552) (in Mutex.cpp, function lock(), line 79)
Jun  9 23:06:41 user1-desktop nvargus-daemon[9273]: (NvCameraUtils) Error InvalidState: Mutex has not been initialized (in Mutex.cpp, function unlock(), line 88)
Jun  9 23:06:41 user1-desktop nvargus-daemon[9273]: (NvCameraUtils) Error InvalidState: Mutex not initialized (/dvs/git/dirty/git-master_linux/camera/core_scf/src/services/gl/EGLStreamProducer.cpp:498) (in Mutex.cpp, function lock(), line 79)
Jun  9 23:06:41 user1-desktop nvargus-daemon[9273]: (NvCameraUtils) Error InvalidState: Mutex has not been initialized (in Mutex.cpp, function unlock(), line 88)
Jun  9 23:06:41 user1-desktop nvargus-daemon[9273]: (NvCameraUtils) Error InvalidState: Mutex not initialized (/dvs/git/dirty/git-master_linux/camera/core_scf/src/services/gl/EGLStreamProducer.cpp:534) (in Mutex.cpp, function lock(), line 79)
Jun  9 23:06:41 user1-desktop nvargus-daemon[9273]: SCF: Error BadParameter:  (propagating from src/services/gl/EGLStreamProducer.cpp, function presentBufferInternal(), line 539)
Jun  9 23:06:41 user1-desktop nvargus-daemon[9273]: (NvCameraUtils) Error InvalidState: Mutex has not been initialized (in Mutex.cpp, function unlock(), line 88)
Jun  9 23:06:41 user1-desktop nvargus-daemon[9273]: (NvCameraUtils) Error InvalidState: Mutex not initialized (/dvs/git/dirty/git-master_linux/camera/core_scf/src/services/gl/EGLStreamProducer.cpp:552) (in Mutex.cpp, function lock(), line 79)
Jun  9 23:06:41 user1-desktop nvargus-daemon[9273]: (NvCameraUtils) Error InvalidState: Mutex has not been initialized (in Mutex.cpp, function unlock(), line 88)
Jun  9 23:06:41 user1-desktop nvargus-daemon[9273]: (NvCameraUtils) Error InvalidState: Mutex not initialized (/dvs/git/dirty/git-master_linux/camera/core_scf/src/services/gl/EGLStreamProducer.cpp:498) (in Mutex.cpp, function lock(), line 79)
Jun  9 23:06:41 user1-desktop nvargus-daemon[9273]: (NvCameraUtils) Error InvalidState: Mutex has not been initialized (in Mutex.cpp, function unlock(), line 88)
Jun  9 23:06:41 user1-desktop nvargus-daemon[9273]: (NvCameraUtils) Error InvalidState: Mutex not initialized (/dvs/git/dirty/git-master_linux/camera/core_scf/src/services/gl/EGLStreamProducer.cpp:534) (in Mutex.cpp, function lock(), line 79)
Jun  9 23:06:41 user1-desktop nvargus-daemon[9273]: SCF: Error BadParameter:  (propagating from src/services/gl/EGLStreamProducer.cpp, function presentBufferInternal(), line 539)
Jun  9 23:06:41 user1-desktop nvargus-daemon[9273]: (NvCameraUtils) Error InvalidState: Mutex has not been initialized (in Mutex.cpp, function unlock(), line 88)
Jun  9 23:06:41 user1-desktop nvargus-daemon[9273]: (NvCameraUtils) Error InvalidState: Mutex not initialized (/dvs/git/dirty/git-master_linux/camera/core_scf/src/services/gl/EGLStreamProducer.cpp:552) (in Mutex.cpp, function lock(), line 79)
Jun  9 23:06:41 user1-desktop nvargus-daemon[9273]: (NvCameraUtils) Error InvalidState: Mutex has not been initialized (in Mutex.cpp, function unlock(), line 88)
Jun  9 23:06:46 user1-desktop nvargus-daemon[9273]: waitForIdleLocked remaining request 5396
Jun  9 23:06:46 user1-desktop nvargus-daemon[9273]: waitForIdleLocked remaining request 5395
Jun  9 23:06:46 user1-desktop nvargus-daemon[9273]: waitForIdleLocked remaining request 5394
Jun  9 23:06:46 user1-desktop nvargus-daemon[9273]: SCF: Error Timeout: waitForIdle() timed out (in src/api/Session.cpp, function waitForIdleLocked(), line 920)
Jun  9 23:06:46 user1-desktop nvargus-daemon[9273]: (Argus) Error Timeout:  (propagating from src/api/CaptureSessionImpl.cpp, function destroy(), line 166)
Jun  9 23:06:51 user1-desktop nvargus-daemon[9273]: waitForIdleLocked remaining request 5396
Jun  9 23:06:51 user1-desktop nvargus-daemon[9273]: waitForIdleLocked remaining request 5395
Jun  9 23:06:51 user1-desktop nvargus-daemon[9273]: waitForIdleLocked remaining request 5394
Jun  9 23:06:51 user1-desktop nvargus-daemon[9273]: SCF: Error Timeout: waitForIdle() timed out (in src/api/Session.cpp, function waitForIdleLocked(), line 920)
Jun  9 23:06:51 user1-desktop nvargus-daemon[9273]: SCF: Error Timeout:  (propagating from src/api/Session.cpp, function abortCaptures(), line 886)
Jun  9 23:06:51 user1-desktop nvargus-daemon[9273]: SCF: Error Timeout:  (propagating from src/api/Session.cpp, function shutdown(), line 400)
Jun  9 23:06:51 user1-desktop nvargus-daemon[9273]: PowerServiceCore:handleRequests: timePassed = 5046
Jun  9 23:06:51 user1-desktop nvargus-daemon[9273]: SCF: Error Timeout:  (propagating from src/api/Session.cpp, function shutdown(), line 500)
Jun  9 23:06:51 user1-desktop nvargus-daemon[9273]: SCF: Error Timeout:  (propagating from src/api/CameraDriver.cpp, function deleteSession(), line 619)
Jun  9 23:06:51 user1-desktop nvargus-daemon[9273]: (Argus) Error Timeout:  (propagating from src/api/CaptureSessionImpl.cpp, function destroy(), line 191)
Jun  9 23:06:51 user1-desktop nvargus-daemon[9273]: === python3[9313]: NOTE: Destroy all libargus objects before destroying the CameraProvider to avoid these warnings.FiberScheduler: 3 fibers still exist!
Jun  9 23:06:51 user1-desktop nvargus-daemon[9273]: === python3[9313]: Connection cleaned up (7F828211D0)free(): invalid size
Jun  9 23:06:52 user1-desktop systemd[1]: nvargus-daemon.service: Main process exited, code=killed, status=6/ABRT
Jun  9 23:06:52 user1-desktop systemd[1]: nvargus-daemon.service: Failed with result 'signal'.
Jun  9 23:06:52 user1-desktop systemd[1]: dummy.service: Main process exited, code=exited, status=1/FAILURE
Jun  9 23:06:52 user1-desktop systemd[1]: dummy.service: Failed with result 'exit-code'.
Jun  9 23:06:52 user1-desktop systemd[1]: nvargus-daemon.service: Service hold-off time over, scheduling restart.
Jun  9 23:06:52 user1-desktop systemd[1]: nvargus-daemon.service: Scheduled restart job, restart counter is at 6.
Jun  9 23:06:52 user1-desktop systemd[1]: Stopped Argus daemon.
Jun  9 23:06:52 user1-desktop systemd[1]: Started Argus daemon.
Jun  9 23:07:12 user1-desktop systemd[1]: dummy.service: Service hold-off time over, scheduling restart.
Jun  9 23:07:12 user1-desktop systemd[1]: dummy.service: Scheduled restart job, restart counter is at 1.
Jun  9 23:07:12 user1-desktop systemd[1]: Stopped Dummy Service.
Jun  9 23:07:12 user1-desktop systemd[1]: Started Dummy Service.
Jun  9 23:07:14 user1-desktop nvargus-daemon[9655]: === NVIDIA Libargus Camera Service (0.97.3)=== Listening for connections...=== python3[9699]: Connection established (7F84BE41D0)OFParserListModules: module list: /proc/device-tree/tegra-camera-platform/modules/module0
Jun  9 23:07:14 user1-desktop nvargus-daemon[9655]: OFParserGetVirtualDevice: NVIDIA Camera virtual enumerator not found in proc device-tree
Jun  9 23:07:14 user1-desktop nvargus-daemon[9655]: ---- imager: No override file found. ----
Jun  9 23:07:14 user1-desktop nvargus-daemon[9655]: LSC: LSC surface is not based on full res!
Jun  9 23:07:14 user1-desktop nvargus-daemon[9655]: === python3[9699]: CameraProvider initialized (0x7f80923880)LSC: LSC surface is not based on full res!
Jun  9 23:07:15 user1-desktop nvargus-daemon[9655]: === python3[9699]: CameraProvider destroyed (0x7f80923880)=== python3[9699]: WARNING: Cleaning up 1 outstanding requests...=== python3[9699]: WARNING: Cleaning up 1 outstanding streams...SCF: Error InvalidState: 5 buffers still pending during EGLStreamProducer destruction (propagating from src/services/gl/EGLStreamProducer.cpp, function freeBuffers(), line 306)
Jun  9 23:07:15 user1-desktop nvargus-daemon[9655]: SCF: Error InvalidState:  (propagating from src/services/gl/EGLStreamProducer.cpp, function ~EGLStreamProducer(), line 50)
Jun  9 23:07:15 user1-desktop nvargus-daemon[9655]: === python3[9699]: WARNING: Cleaning up 1 outstanding stream settings...=== python3[9699]: WARNING: Cleaning up 1 outstanding sessions...(NvCameraUtils) Error InvalidState: Mutex not initialized (/dvs/git/dirty/git-master_linux/camera/core_scf/src/services/gl/EGLStreamProducer.cpp:498) (in Mutex.cpp, function lock(), line 79)
Jun  9 23:07:15 user1-desktop nvargus-daemon[9655]: SCF: Error BadParameter: Buffer is not pending (in src/services/gl/EGLStreamProducer.cpp, function presentBufferInternal(), line 502)
Jun  9 23:07:15 user1-desktop nvargus-daemon[9655]: (NvCameraUtils) Error InvalidState: Mutex has not been initialized (in Mutex.cpp, function unlock(), line 88)
Jun  9 23:07:15 user1-desktop nvargus-daemon[9655]: SCF: Error BadParameter:  (propagating from src/services/gl/EGLStreamProducer.cpp, function presentBuffer(), line 487)
Jun  9 23:07:15 user1-desktop nvargus-daemon[9655]: SCF: Error BadParameter:  (propagating from src/components/CaptureContainerImpl.cpp, function returnBuffer(), line 447)
Jun  9 23:07:15 user1-desktop nvargus-daemon[9655]: SCF: Error BadParameter:  (propagating from src/components/stages/BufferReturnStage.h, function doExecute(), line 43)
Jun  9 23:07:15 user1-desktop nvargus-daemon[9655]: SCF: Error BadParameter: Sending critical error event (in src/api/Session.cpp, function sendErrorEvent(), line 990)
Jun  9 23:07:15 user1-desktop nvargus-daemon[9655]: (NvCameraUtils) Error InvalidState: Mutex not initialized (/dvs/git/dirty/git-master_linux/camera/core_scf/src/services/gl/EGLStreamProducer.cpp:498) (in Mutex.cpp, function lock(), line 79)
Jun  9 23:07:15 user1-desktop nvargus-daemon[9655]: (NvCameraUtils) Error InvalidState: Mutex has not been initialized (in Mutex.cpp, function unlock(), line 88)
Jun  9 23:07:15 user1-desktop nvargus-daemon[9655]: (NvCameraUtils) Error InvalidState: Mutex not initialized (/dvs/git/dirty/git-master_linux/camera/core_scf/src/services/gl/EGLStreamProducer.cpp:534) (in Mutex.cpp, function lock(), line 79)
Jun  9 23:07:15 user1-desktop nvargus-daemon[9655]: SCF: Error BadParameter:  (propagating from src/services/gl/EGLStreamProducer.cpp, function presentBufferInternal(), line 539)
Jun  9 23:07:15 user1-desktop nvargus-daemon[9655]: (NvCameraUtils) Error InvalidState: Mutex has not been initialized (in Mutex.cpp, function unlock(), line 88)
Jun  9 23:07:15 user1-desktop nvargus-daemon[9655]: (NvCameraUtils) Error InvalidState: Mutex not initialized (/dvs/git/dirty/git-master_linux/camera/core_scf/src/services/gl/EGLStreamProducer.cpp:552) (in Mutex.cpp, function lock(), line 79)
Jun  9 23:07:15 user1-desktop nvargus-daemon[9655]: (NvCameraUtils) Error InvalidState: Mutex has not been initialized (in Mutex.cpp, function unlock(), line 88)
Jun  9 23:07:15 user1-desktop nvargus-daemon[9655]: (NvCameraUtils) Error InvalidState: Mutex not initialized (/dvs/git/dirty/git-master_linux/camera/core_scf/src/services/gl/EGLStreamProducer.cpp:498) (in Mutex.cpp, function lock(), line 79)
Jun  9 23:07:15 user1-desktop nvargus-daemon[9655]: (NvCameraUtils) Error InvalidState: Mutex has not been initialized (in Mutex.cpp, function unlock(), line 88)
Jun  9 23:07:15 user1-desktop nvargus-daemon[9655]: (NvCameraUtils) Error InvalidState: Mutex not initialized (/dvs/git/dirty/git-master_linux/camera/core_scf/src/services/gl/EGLStreamProducer.cpp:534) (in Mutex.cpp, function lock(), line 79)
Jun  9 23:07:15 user1-desktop nvargus-daemon[9655]: SCF: Error BadParameter:  (propagating from src/services/gl/EGLStreamProducer.cpp, function presentBufferInternal(), line 539)
Jun  9 23:07:15 user1-desktop nvargus-daemon[9655]: (NvCameraUtils) Error InvalidState: Mutex has not been initialized (in Mutex.cpp, function unlock(), line 88)
Jun  9 23:07:15 user1-desktop nvargus-daemon[9655]: (NvCameraUtils) Error InvalidState: Mutex not initialized (/dvs/git/dirty/git-master_linux/camera/core_scf/src/services/gl/EGLStreamProducer.cpp:552) (in Mutex.cpp, function lock(), line 79)
Jun  9 23:07:15 user1-desktop nvargus-daemon[9655]: (NvCameraUtils) Error InvalidState: Mutex has not been initialized (in Mutex.cpp, function unlock(), line 88)
Jun  9 23:07:15 user1-desktop nvargus-daemon[9655]: (NvCameraUtils) Error InvalidState: Mutex not initialized (/dvs/git/dirty/git-master_linux/camera/core_scf/src/services/gl/EGLStreamProducer.cpp:498) (in Mutex.cpp, function lock(), line 79)
Jun  9 23:07:15 user1-desktop nvargus-daemon[9655]: (NvCameraUtils) Error InvalidState: Mutex has not been initialized (in Mutex.cpp, function unlock(), line 88)
Jun  9 23:07:15 user1-desktop nvargus-daemon[9655]: (NvCameraUtils) Error InvalidState: Mutex not initialized (/dvs/git/dirty/git-master_linux/camera/core_scf/src/services/gl/EGLStreamProducer.cpp:534) (in Mutex.cpp, function lock(), line 79)
Jun  9 23:07:15 user1-desktop nvargus-daemon[9655]: SCF: Error BadParameter:  (propagating from src/services/gl/EGLStreamProducer.cpp, function presentBufferInternal(), line 539)
Jun  9 23:07:15 user1-desktop nvargus-daemon[9655]: (NvCameraUtils) Error InvalidState: Mutex has not been initialized (in Mutex.cpp, function unlock(), line 88)
Jun  9 23:07:15 user1-desktop nvargus-daemon[9655]: (NvCameraUtils) Error InvalidState: Mutex not initialized (/dvs/git/dirty/git-master_linux/camera/core_scf/src/services/gl/EGLStreamProducer.cpp:552) (in Mutex.cpp, function lock(), line 79)
Jun  9 23:07:15 user1-desktop nvargus-daemon[9655]: (NvCameraUtils) Error InvalidState: Mutex has not been initialized (in Mutex.cpp, function unlock(), line 88)
Jun  9 23:07:15 user1-desktop nvargus-daemon[9655]: (NvCameraUtils) Error InvalidState: Mutex not initialized (/dvs/git/dirty/git-master_linux/camera/core_scf/src/services/gl/EGLStreamProducer.cpp:498) (in Mutex.cpp, function lock(), line 79)
Jun  9 23:07:15 user1-desktop nvargus-daemon[9655]: (NvCameraUtils) Error InvalidState: Mutex has not been initialized (in Mutex.cpp, function unlock(), line 88)
Jun  9 23:07:15 user1-desktop nvargus-daemon[9655]: (NvCameraUtils) Error InvalidState: Mutex not initialized (/dvs/git/dirty/git-master_linux/camera/core_scf/src/services/gl/EGLStreamProducer.cpp:534) (in Mutex.cpp, function lock(), line 79)
Jun  9 23:07:15 user1-desktop nvargus-daemon[9655]: SCF: Error BadParameter:  (propagating from src/services/gl/EGLStreamProducer.cpp, function presentBufferInternal(), line 539)
Jun  9 23:07:15 user1-desktop nvargus-daemon[9655]: (NvCameraUtils) Error InvalidState: Mutex has not been initialized (in Mutex.cpp, function unlock(), line 88)
Jun  9 23:07:15 user1-desktop nvargus-daemon[9655]: (NvCameraUtils) Error InvalidState: Mutex not initialized (/dvs/git/dirty/git-master_linux/camera/core_scf/src/services/gl/EGLStreamProducer.cpp:552) (in Mutex.cpp, function lock(), line 79)
Jun  9 23:07:15 user1-desktop nvargus-daemon[9655]: (NvCameraUtils) Error InvalidState: Mutex has not been initialized (in Mutex.cpp, function unlock(), line 88)
Jun  9 23:07:20 user1-desktop nvargus-daemon[9655]: waitForIdleLocked remaining request 108
Jun  9 23:07:20 user1-desktop nvargus-daemon[9655]: waitForIdleLocked remaining request 107
Jun  9 23:07:20 user1-desktop nvargus-daemon[9655]: waitForIdleLocked remaining request 106
Jun  9 23:07:20 user1-desktop nvargus-daemon[9655]: waitForIdleLocked remaining request 105
Jun  9 23:07:20 user1-desktop nvargus-daemon[9655]: SCF: Error Timeout: waitForIdle() timed out (in src/api/Session.cpp, function waitForIdleLocked(), line 920)
Jun  9 23:07:20 user1-desktop nvargus-daemon[9655]: (Argus) Error Timeout:  (propagating from src/api/CaptureSessionImpl.cpp, function destroy(), line 166)
Jun  9 23:07:25 user1-desktop nvargus-daemon[9655]: waitForIdleLocked remaining request 108
Jun  9 23:07:25 user1-desktop nvargus-daemon[9655]: waitForIdleLocked remaining request 107
Jun  9 23:07:25 user1-desktop nvargus-daemon[9655]: waitForIdleLocked remaining request 106
Jun  9 23:07:25 user1-desktop nvargus-daemon[9655]: waitForIdleLocked remaining request 105
Jun  9 23:07:25 user1-desktop nvargus-daemon[9655]: SCF: Error Timeout: waitForIdle() timed out (in src/api/Session.cpp, function waitForIdleLocked(), line 920)
Jun  9 23:07:25 user1-desktop nvargus-daemon[9655]: SCF: Error Timeout:  (propagating from src/api/Session.cpp, function abortCaptures(), line 886)
Jun  9 23:07:25 user1-desktop nvargus-daemon[9655]: SCF: Error Timeout:  (propagating from src/api/Session.cpp, function shutdown(), line 400)
Jun  9 23:07:25 user1-desktop nvargus-daemon[9655]: PowerServiceCore:handleRequests: timePassed = 5054
Jun  9 23:07:25 user1-desktop nvargus-daemon[9655]: SCF: Error Timeout:  (propagating from src/api/Session.cpp, function shutdown(), line 500)
Jun  9 23:07:25 user1-desktop nvargus-daemon[9655]: SCF: Error Timeout:  (propagating from src/api/CameraDriver.cpp, function deleteSession(), line 619)
Jun  9 23:07:25 user1-desktop nvargus-daemon[9655]: (Argus) Error Timeout:  (propagating from src/api/CaptureSessionImpl.cpp, function destroy(), line 191)
Jun  9 23:07:25 user1-desktop nvargus-daemon[9655]: === python3[9699]: NOTE: Destroy all libargus objects before destroying the CameraProvider to avoid these warnings.FiberScheduler: 4 fibers still exist!
Jun  9 23:07:26 user1-desktop nvargus-daemon[9655]: === python3[9699]: Connection closed (7F84BE41D0)=== python3[9699]: Connection cleaned up (7F84BE41D0)free(): invalid size
Jun  9 23:07:26 user1-desktop systemd[1]: dummy.service: Main process exited, code=exited, status=1/FAILURE
Jun  9 23:07:26 user1-desktop systemd[1]: dummy.service: Failed with result 'exit-code'.
Jun  9 23:07:26 user1-desktop systemd[1]: nvargus-daemon.service: Main process exited, code=killed, status=6/ABRT
Jun  9 23:07:26 user1-desktop systemd[1]: nvargus-daemon.service: Failed with result 'signal'.
Jun  9 23:07:27 user1-desktop systemd[1]: nvargus-daemon.service: Service hold-off time over, scheduling restart.
Jun  9 23:07:27 user1-desktop systemd[1]: nvargus-daemon.service: Scheduled restart job, restart counter is at 7.
Jun  9 23:07:27 user1-desktop systemd[1]: Stopped Argus daemon.
Jun  9 23:07:27 user1-desktop systemd[1]: Started Argus daemon.

Here is the output:

# R32 (release), REVISION: 4.3, GCID: 21589087, BOARD: t210ref, EABI: aarch64, DATE: Fri Jun 26 04:38:25 UTC 2020

By the way, I tried to stop dummy.service and run video2.py manually and everyhing seems ok. But it may crash some time later, though. As I understand, appropriate logs are as follows:

Jun  9 23:09:53 user1-desktop nvargus-daemon[10279]: === NVIDIA Libargus Camera Service (0.97.3)=== Listening for connections...=== python3[10368]: Connection established (7FAB4311D0)OFParserListModules: module list: /proc/device-tree/tegra-camera-platform/modules/module0
Jun  9 23:09:53 user1-desktop nvargus-daemon[10279]: OFParserGetVirtualDevice: NVIDIA Camera virtual enumerator not found in proc device-tree
Jun  9 23:09:53 user1-desktop nvargus-daemon[10279]: ---- imager: No override file found. ----
Jun  9 23:09:53 user1-desktop nvargus-daemon[10279]: LSC: LSC surface is not based on full res!
Jun  9 23:09:53 user1-desktop nvargus-daemon[10279]: === python3[10368]: CameraProvider initialized (0x7fa49238b0)LSC: LSC surface is not based on full res!
Jun  9 23:11:24 user1-desktop systemd[1]: Starting Cleanup of Temporary Directories...
Jun  9 23:11:24 user1-desktop systemd[1]: Started Cleanup of Temporary Directories.

Hi,
It still looks like the camera source is not stable. Please try simple gstreamer command like:

gst-launch-1.0 nvarguscamerasrc ! nvoverlaysink

See if you can launch it and see camera preview.

Yes, I connected the monitor and everything is OK - I see the videostream. Here is a piece of log:

Jun 10 21:03:55 user1-desktop nvargus-daemon[10525]: === NVIDIA Libargus Camera Service (0.97.3)=== Listening for connections...=== gst-launch-1.0[10684]: Connection established (7FA6D911D0)OFParserListModules: module list: /proc/device-tree/tegra-camera-platform/modules/module0
Jun 10 21:03:55 user1-desktop nvargus-daemon[10525]: OFParserGetVirtualDevice: NVIDIA Camera virtual enumerator not found in proc device-tree
Jun 10 21:03:55 user1-desktop nvargus-daemon[10525]: ---- imager: No override file found. ----
Jun 10 21:03:56 user1-desktop nvargus-daemon[10525]: LSC: LSC surface is not based on full res!
Jun 10 21:03:56 user1-desktop nvargus-daemon[10525]: === gst-launch-1.0[10684]: CameraProvider initialized (0x7fa08fd040)LSC: LSC surface is not based on full res!

Maybe something in my code leads to crash and it tries to initialize a new connection with camera after restart, which causes mistakesin syslog?

I wrapped my while loop with try-except block and found some details.

In my log I see this:

2021-06-10 22:56:21,754 :: DEBUG :: ___Status: True, Shape: (1080, 1920, 3)___
2021-06-10 22:56:22,322 :: ERROR :: Failure with 'NoneType' object has no attribute 'shape'
2021-06-10 22:56:23,632 :: DEBUG :: ___Status: True, Shape: (1080, 1920, 3)___

which means that at 22:56:22,322 status, frame = capture.read() failded.

At the same time in syslog I get the following:

Jun 10 22:55:56 user1-desktop nvargus-daemon[5288]: === python3[5638]: CameraProvider initialized (0x7f947d0c10)LSC: LSC surface is not based on full res!
Jun 10 22:55:56 user1-desktop systemd[1]: Started Session c2 of user gdm.
Jun 10 22:56:01 user1-desktop systemd-timesyncd[3667]: Synchronized to time server 195.112.113.253:123 (1.pool.ntp.org).
Jun 10 22:56:21 user1-desktop CRON[4065]: (CRON) info (No MTA installed, discarding output)
Jun 10 22:56:22 user1-desktop nvargus-daemon[5288]: === python3[6758]: Connection established (7F52FFD1D0)=== python3[6758]: CameraProvider initialized (0x187f2e70)(Argus) Error AlreadyAllocated: Device 0 (of 1) is in use (in src/api/CameraProviderImpl.cpp, function createCaptureSession(), line 236)
Jun 10 22:56:23 user1-desktop CRON[4068]: (CRON) info (No MTA installed, discarding output)

So, at the same time connection was established again. But I have no idea why it happens - this rarely happens, judging by my log.